打印出C# 中float ,double 在内存中的存放形式

 1             float floatA = 2.2f;
 2             uint a = BitConverter.ToUInt32(BitConverter.GetBytes(floatA), 0);
 3             for (int i = 0; i < 32;++i )
 4             {
 5                 uint temp = 0x80000000 & (a << i);
 6                 if (temp==0)
 7                 {
 8                     Console.Write("0 ");
 9                 }
10                 else
11                 {
12                     Console.Write("1 ");
13                 }
14             }
15 
16             Console.WriteLine();
17 
18             double doubleA = 2.2;
19             ulong b = BitConverter.ToUInt64(BitConverter.GetBytes(doubleA), 0);
20             for (int i = 0; i < 64; ++i)
21             {
22                 ulong temp = 0x8000000000000000 & (b << i);
23                 if (temp == 0)
24                 {
25                     Console.Write("0 ");
26                 }
27                 else
28                 {
29                     Console.Write("1 ");
30                 }
31             }

 

打印出C# 中float ,double 在内存中的存放形式

上一篇:WPF 虚拟键盘


下一篇:windows下配置Tomcat7.0.22