Domanda

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.

I've narrowed it down to IEEE 754. So I need to somehow convert a float in Java such as:

    float num = 504.0f;

to this value: 43FC0000

Any help would be appreciated as I really need this for a RTE project I'm working on. Thanks

È stato utile?

Soluzione

That'll be Integer.toHexString(Float.floatToIntBits(num)).toUpperCase()

Not sure if you want to left pad this with zeroes.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top