Floating Point Numbers – Computerphile

44
23



Why can’t floating point do money? It’s a brilliant solution for speed of calculations in the computer, but how and why does moving the decimal point (well, in this case binary or radix point) help and how does it get currency so wrong?

3D Graphics Playlist:
The Trouble with Timezones:

More from Tom Scott: and

This video was filmed and edited by Sean Riley.

Computerphile is a sister project to Brady Haran’s Numberphile. See the full list of Brady’s video projects at:

Nguồn:https://dothihoa.com/

44 COMMENTS

  1. The problem with 0.1+0.2 not being equal to 0.3 is not that the 0.3 isn't accurate – it's the conversion of 0.1 to floating point storage and the conversion 0f 0.2 to floating point storage that loses the accuracy right there. The addition is actually perfectly accurate – the accuracy was already lost BEFORE the addition =)

  2. I was only one minute into the video and you already answered my questions! I am no a specialist and literally have no idea what floating points are/ after hours of searching this is the first video that makes sense to me !! thanks

  3. What if the universe is like a computer that uses floating-point numbers? What if the universe only stores values down to a certain, very large but finite, number of bits?

  4. I've taken five semesters of calculus, chemistry, and several engineering and physics classes. I've used scientific notation for years…and this video is the first time I've heard an explanation for WHY scientific notation is used.

  5. i hate recuring numbers like your example adding 1/3s because i hate that it doesnt work and its not really right when we use decimals. knew i was autistic or something now i know im just a bit computer.

  6. Try coding a Mac Lauren series on a 4slice array processor which has NO division…

    BTW, division is the most “expensive” simple arithmetic operation within any computer.

  7. thats why we round number. so it will be back correct LOL and floating point can be exact. fraction is that PROBLEM. genious what school he go 😛 1/3 + 1/3 + 1/3 =0.9999999..infinity but if you roundup it for lets say 1 billion decimal acuraty it will be still 1 LOL

  8. Hah, this reminds me of a programming exercise that I had to undertake in Algorithms 2. The teacher wanted us to calculate a continuous moving average for a set of values. Since the data requirement was so minimal, I decided to store the last n digits in an array, and cycle through them when new numbers appeared. When needed, the moving average was calculated by adding the numbers together and dividing by n.

    My program would fail the automated test, because it failed to include the almost 3% error that the professor had gotten by updating a floating point average value for every step of the calculation. I had to teach about 5 other students about the fact that their program was too accurate, and needed to be downgraded.

  9. 3:48 I don't understand. Why does base 2 do fractions as one half, one quarter, etc. Why doesn't it do it as 0.1, 0.2, 0.4, 0.8 – the same as it does whole numbers?

  10. But wait… who the hell uses fractions in coding, first of all? Secondly, most floating point needs arise from computing money, and so yes, rounding is acceptable and necessary. I get the fact of floating precision and computing limits, but it does have its place. Some say store money as cents… not sure how much that matters… it always comes back round to 2 decimal payouts

  11. I prefer 3 bit floats. They have 1 sign bit, 1 exponent bit, and 1 significand bit. They can encode ±0, ±1, ±∞, and NaN, which is all you really need.

  12. I have a computer science degree from a top school, and yet nothing was ever explained nearly as well as this.

    I love this YouTube channel. Absolutely brilliant explaination. Thank you!!

  13. Feel like his voice changed a bit. Less British or something lol. Also wow, I first subscribed to his own channel then I discovered this one. So what does he actually do???

  14. Sorry to comment on a video from 4 years ago, but why don't modern compilers suffer from this anymore? For example, adding 0.20 and 0.10 in Visual Studio gives you 0.30 (0.3). Doesn't this mean the rounding point error has been removed?

  15. How I deal with this is I write numbers in a string, then explode that and make an array of character and cast each to an int, then I do the calculation and return it in a float format. It literally has never failed me…

LEAVE A REPLY

Please enter your comment!
Please enter your name here