samedi 28 février 2015

C++ convert float to hex using only whole number math


I need to convert a whole number that should be considered a float into its hexadecimal equivalent.


For example:



Float To Hex


1 = 0x3f800000


2 = 0x40000000


12345 = 0x4640e400



It will always be whole numbers, never fractions such as 0.5. This could be done with memory assignment or a formatting function, but the situation its being used it, it has no memory access and no API calls at all.


I tried this idea, but it doesn't work at all http://ift.tt/1wyZvuW




Aucun commentaire:

Enregistrer un commentaire