I dont get why floating points are such a big deal in C, as I am reading my C book and it seems like they put a lot of emphasis on floating point. But all that I get is that floating point #'s are basically decimal #'s. What more is to say about it?
I dont get why floating points are such a big deal in C, as I am reading my C book and it seems like they put a lot of emphasis on floating point. But all that I get is that floating point #'s are basically decimal #'s. What more is to say about it?
On many computers that use IEEE floating point standards, floats and doubles are inaccurate. Many floats cannot be represented accurately, and compring two floats (or double) for equality may fail when logic says they should be the same. Higher-level mathametical problems will have more use for floats/doubles than you find in most "normal" applicaton programs.
Last edited by Ancient Dragon; 09-20-2005 at 02:45 PM.
Basically, the point is, don't think "floating point number." Think "floating point approximation."
Thanks, I am reading a nice wikipedia article on floating point right now. Quick question why does it not print "10.2" but "10.200000"
Code:#include <stdio.h> int main(void) { float value = 10.2; printf("The number is %f\n", value); return 0; }
>Quick question why does it not print "10.2" but "10.200000"
http://dev.unicals.com/c89-draft.html#4.9.6.1f The double argument is converted to decimal notation in the style [-]ddd.ddd , where the number of digits after the decimal-point character is equal to the precision specification. If the precision is missing, it is taken as 6; if the precision is explicitly zero, no decimal-point character appears. If a decimal-point character appears, at least one digit appears before it. The value is rounded to the appropriate number of digits.
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
thanks mate