FP Question
-
-
Thnkx a lot for "floating point comparisions"............. Does this mean IEEE32/64 arent good enough to store FPs accurately AND wat when we use the same number to print on screen......i mean how is that FP printed accurately?
Spread wat u Know!
Read What Every Computer Scientist Should Know About Floating Point Arithmetic[^]. A binary floating-point number can only store numbers that are sums of powers of two. The digits to the right of the point are sums of negative powers of two. Just as 1/3 is not accurately representable in decimal (0.33333.... etc), 1/5 is not accurately representable in binary. The more operations you perform on a limited precision representation, the more representation error builds up. That's why it's rarely a good idea to directly compare two floating point numbers. I don't think there are any values representable in binary that are not representable in decimal, because two divides evenly into ten. However, when displaying a floating point result, it's common to only show some decimal places, displaying a rounded result. If you want decimal values, with a fixed decimal point, to be stored and computed accurately, you should use a scaled integer. This is not supplied by standard C++ so you'll have to find an implementation, e.g. here[^].
Stability. What an interesting concept. -- Chris Maunder