In Week 2 Lecture (the first one), Mr. Malan says a reason for floating - point imprecision (40:00). I don't get his reason. Sorry for the bad question, but please explain...
Thanks in advance.
While it is easy to represent integers in a computer, it is different for floating point numbers. Most FP numbers cannot be precisely represented inside a computer. The reason is because numbers are represented in base 2 in a computer, but most base 10 fractions can't be represented by base 2 systems. For a detailed explanation, you might try googling for base 2 representation and storage of floating point numbers in computers.
Simply put, a float may appear to be accurately stored, until you look at it to a high number of digits. For example, 4.2 may print out as 4.2 on your computer, but if you change the number of digits to be printed, you'll find that 4.2 is actually stored in a computer as something like 4.199999998753 (this is just an example, your numbers may differ.)
If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)
First you must understand that there are infinite floating numbers between any two numbers, so floating points between
1.0 are infinite.
If you have limited number of pointers and you want to represent those numbers, you would only be able to represent subset of them, and round all numbers in between.
Let's say you have only
3 pointers to represent numbers between 0 and 1, you may choose
[0.25,0.5,0.75], as your pointers, that means if you want to represent
0.45 you would use
Floating types has finite number of digits so it can only represent a subset of the floating point spectrum.
Look at Cliff B answer for a more Accurate explanation. Also, I found this video Floating Point Numbers - Computerphileto be very helpful.