Decoding Floats
raysohn.com
Decoding Floats
1–6 of 6 posts
Re: Decoding Floats
#2Re: Decoding Floats
#3[Wrong!] Nitpick from the article: the main is declared as returning an int and there is nothing returned.
Re: Decoding Floats
#4In 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.
Re: Decoding Floats
#5In 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.
Not return-ing but just falling through to the closing } is perfectly fine and defined as returning 0.
"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!
Re: Decoding Floats
#6In 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.
Not return-ing but just falling through to the closing } is perfectly fine and defined as returning 0.
"If the return type of the main function is a type compatible with int, a return from the initial call to the main function is equivalent to calling the exit function with the value returned by the main function as its argument; 11) reaching the } that terminates the main function returns a value of 0." ( http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf, 5.1.2.2.3 Program termination )