Link to home
Start Free TrialLog in
Avatar of kimfink
kimfink

asked on

How to convert double to hex?

How can I convert a double to hex?
Is there any methods in the .NET framework for this?

Tnx.
ASKER CERTIFIED SOLUTION
Avatar of josgood
josgood
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kimfink
kimfink

ASKER

Hi,

how does this work if the double is 10.0, this do not convert to A which it would for a integer, it converts to 4024000000000000. Why?
Sometimes the double would be 10.0 for example, and sometimes it could be 12.3456.
Integers and floating point values are represented differently.  An integer 10 will be stored in memory as hex 0A, as you said.

However, IEEE defines different representations for floating point, as discussed at
http://en.wikipedia.org/wiki/IEEE_floating-point_standard

So you'll never see 0x0A when looking at a floating-point 10.