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.
.NET ProgrammingC#

Avatar of undefined
Last Comment
josgood

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
josgood

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
kimfink

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.
josgood

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.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes