Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: Float/double to hex?

by Anonymous Monk
on Feb 18, 2013 at 01:35 UTC ( #1019258=note: print w/ replies, xml ) Need Help??


in reply to Re: Float/double to hex?
in thread Float/double to hex?

Well, FWIW, https://www.wolframalpha.com/input/?i=1%20%2F%207%20%3D%200.142857142857143%20%3D%200x6FDF1234 seems to poop it out just fine

I figure it is https://en.wikipedia.org/wiki/Single-precision_floating-point_format but I can't get it correct

I can get https://en.wikipedia.org/wiki/Single-precision_floating-point_format#Single-precision_examples on my machine (3eaa aaab ≈ 1/3) with

$ perl -le " print unpack 'H*', pack 'f>', 1/3 3eaaaaab
but basically I tired brute forced it :)

I also saw these and they might have something to do with it, but the bits got me :) Network IEEE 754 to Native Floats: which pack/unpack ops better?, Extracting IEEE 754 floating point numbers


Comment on Re^2: Float/double to hex?
Download Code
Re^3: Float/double to hex?
by Anonymous Monk on Feb 18, 2013 at 01:37 UTC
    HA! I completely got fooled by wolfraudalpha
Re^3: Float/double to hex?
by BrowserUk (Pope) on Feb 18, 2013 at 01:56 UTC

    I've no idea what that hex value is, but it certainly isn't any IEEE representation of 1/7.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re^3: Float/double to hex?
by Mr. Muskrat (Abbot) on Feb 18, 2013 at 18:21 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1019258]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2014-10-22 07:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (114 votes), past polls