Java浮点到IEEE-754十六进制? [英] Java float to IEEE-754 hexadecimal?
问题描述
我现在一直在寻找关于这个问题的答案大概2个小时,我似乎无法摆脱它的困扰。我需要将java中的32位单浮点值转换为十六进制字符串。
I've been searching for an answer to this all over for about 2 hours now, I can't seem to get my head around it. I need to convert a 32 bit single floating point value in java to a hexadecimal string.
我已将范围缩小到IEEE 754.因此,我需要以某种方式将在Java中浮动,例如:
I've narrowed it down to IEEE 754. So I need to somehow convert a float in Java such as:
float num = 504.0f;
至此值:43FC0000
to this value: 43FC0000
任何帮助将不胜感激,因为我真的需要这个我正在工作的RTE项目。
由于
Any help would be appreciated as I really need this for a RTE project I'm working on. Thanks
推荐答案
这会 Integer.toHexString(Float.floatToIntBits(NUM) ).toUpperCase()
不确定是否要将这个零填充。
Not sure if you want to left pad this with zeroes.
这篇关于Java浮点到IEEE-754十六进制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!