float to binary

CSharp · Console

/Program.cs

using System;
using System.Linq;
			
public class Program
{
	public static void Main()
	{
		var res = BitConverter.GetBytes(3.141f)
			.Reverse()
			.Select(x => Convert.ToString(x, 2))
			.Select(x => x.PadLeft(8, '0'))
			.Aggregate("0b", (a, b) => a + "_" + b);
		
		Console.WriteLine(res);
	}
}
;