[dba-Tech] Conversion of REAL decimal numbers to Hex

Josh McFarlane darsant at gmail.com
Tue Mar 21 12:22:38 CST 2006


On 3/21/06, Steve Erbach <erbachs at gmail.com> wrote:
> I did find an on-line calculator:
>
> http://babbage.cs.qc.edu/courses/cs341/IEEE-754.html
>
> Apparently, there's a standard way to represent floating point numbers
> in hex, but the resulting Hex number doesn't have a "decimal" point.
> For example, 1.07 (decimal) comes out as 3FF11EB851EB851F using a
> 64-bit double precision hex number.  You can see the string "11EB85"
> in that number, the same that I came up with manually, but I'm still
> puzzling over the beginning 3FF.

Steve -

They're actually encoding it into the binary representation of a
floating point number, rather than a straight conversion of a decimal
value to hexadecimal

Basically, they're encoding it to something akin to X.XXXXXX * 10 ^ YY

However, a straight representation would be slightly different.

If you want just a straight up conversion of Decimal --> Hex, this
will be different than the hex value listed on the page (as it's
"encoded" according to the nice tables)

--
Josh McFarlane

"Peace cannot be kept by force. It can only be achieved by understanding."
-Albert Einstein



More information about the dba-Tech mailing list