Compare binary representation of floats in C# and MSSQL

CSharp · Console

/Program.cs

using System;
					
public class Program
{
	public static void Main()
	{
		const string formatter = "{0,20}";
		var t = 3.141598265358979323846264338d;
		var m = 100000000000000000000d;
		var b = BitConverter.GetBytes(t / m);
		Console.WriteLine(formatter, BitConverter.ToString( b ) );
		
// For comparison to show compatibility with MSSQL
// declare @t float;
// declare @m float;
// set @t = 3.141598265358979323846264338;
// set @m = 100000000000000000000;
// select convert(varbinary, @t / @m);
		
	}
}
;