
Decoding Floats - luu
http://raysohn.com/posts/decoding-floats.html
======
rainbowgarden
When dealing with floats, it should be noted that unlike a 32-bit `int` which
is a signed 2's complement representation; a 32-bit `float` follows single
precision floating point representation which is 1 sign bit, 8 exponent bits
and 23 mantissa bits. Not that there's anything wrong with the article, i just
wanted to put it here.

------
las_cases
In college, I remember we had to manually encode / decode a binary float to a
decimal float as exercises. While it was rather fun to understand how machines
store a float it could get messy with 64 bits. Also, completely ridiculous
tasks.

[Wrong!] Nitpick from the article: the main is declared as returning an int
and there is nothing returned.

~~~
Tomte
Not return-ing but just falling through to the closing } is perfectly fine and
defined as returning 0.

~~~
mattgodbolt
To clarify: this is _only_ for main(), in C++: (see c3.6.1p5 of the standard)

"A return statement in main has the effect of leaving the main function
(destroying any objects with auto- matic storage duration) and calling exit
with the return value as the argument. If control reaches the end of main
without encountering a return statement, the effect is that of executing
return 0"

It's really best not to get in the habit of not returning from a function
though, as in the vast majority of cases, you'll get a random value (well,
whatever's in the appropriate register) as the return result, and unless you
specifically configure it, most compilers won't even warn you!

