双转换为十六进制在C# [英] Convert double into hex in C#
本文介绍了双转换为十六进制在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个值:
双headingAngle = 135.34375;
double headingAngle = 135.34375;
我想将它转化成HEX和打印HEX到控制台。我已经转换为字符串和int到各自的十六进制值,而是一个双似乎更加棘手。有人能指出我在正确的方向?
I would like to convert it to HEX and print the HEX to the console. I have already converted a string and int into their respective HEX values, but a double seems to be much more tricky. Can someone point me in the right direction?
推荐答案
好吧,我GOOGLE了一两分钟,并根据的this
是一个相当ellegant解决方案
Well, I googled for a minute or two and according to this here is a quite ellegant solution
double d = 12.09;
Console.WriteLine("Double value: " + d.ToString());
byte[] bytes = BitConverter.GetBytes(d);
Console.WriteLine("Byte array value:");
Console.WriteLine(BitConverter.ToString(bytes));
这篇关于双转换为十六进制在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文