Floating Point Numbers - Computerphile
Channel:Computerphile · Length:9:16 · Published:2014-01-22 · Views:2545912
Summary
Tom Scott explains for Computerphile how floating point numbers work, why moving the binary point is fast, and why it handles money badly.
Why HN recommends it
Recommended as a simple, fun explanation of why floating point gives odd errors like 0.1 + 0.2.
Tom Scott's fun and simple take on Floating Points is a good video explaining why such weird errors happen — HN, 2015
Information theory & signal processing · Computer architecture & CPUs
Subtitles (excerpt)
People expect computers to be entirely accurate and precise with numbers. You know, you grow up with calculators. You expect that if you type in: "0.1 + 0.2", you expect it to come out to "0.3". And sooner or later every programmer, as they're learning, tries something like that. And they type it into a programming language. Something like "0.1 + 0.2", and they will hit Enter, and what the computer will give them is something like "0.300000000...1". And at that point, they will have started to learn about floating point numbers, and they will be starting to tear their hair out. Floating point numbers are essentially scientific notation. For the uninitiated, let's say you're an astrophysicist, and you have the speed of light, which is this enormous number with eight 0s after it. And you want to multiply it by a tiny distance. It doesn't really matter what we're measuring here, it's just a big number and a small number. Let's say, 0.00000015. Let's say you want to multiply these two together. (I may have made this a bit deliberately easy.) You could try and do some really complicated maths and work it all out, but you don't need to. Because in scientific notation, this is 3 times 10 to the 8,
On Hacker News
Short answer, no decimal in binary and math is hard. :) Here's a couple handy videos explaining it: [VIDEO] [LINK] — microwavecamera, 2017-06
Recommended: Floating Point Numbers - Computerphile [VIDEO] Tom Scott's fun and simple take on Floating Points is a good video explaining why such weird errors happen — felipesabino, 2015-11
You should still not use MONEY in Postgres, even their own website says so [1]. I still wouldn't use floats/numerics/decimals to store currency either in any db generally, as said by others you're going to end up with inaccurate numbers [2]. Therefore using integers is in fact very good for this use-case, especially if you are in accounting or book-keeping! Source: I work for a Fintech company th… — mercxry, 2023-10
Related videos
- Net Neutrality: Last Week Tonight with John Oliver (HBO) · LastWeekTonight · 13:18
- "Turning the database inside out with Apache Samza" by Martin Kleppmann · Strange Loop Conference · 47:42
- But what is the Fourier Transform? A visual introduction. · 3Blue1Brown · 19:41
- D/A and A/D | Digital Show and Tell (Monty Montgomery @ xiph.org) · FL Studio · 23:52
- 8-bit computer update · Ben Eater · 6:53
- Light Years Ahead | The 1969 Apollo Guidance Computer · TNMoC · 1:21:22
- “Hello, world” from scratch on a 6502 — Part 1 · Ben Eater · 27:24
- Finding the Missing Memristor - R. Stanley Williams · The Qualcomm Institute · 47:52
- The Ultimate Game Boy Talk (33c3) · media.ccc.de · 1:01:06
- The Thirty Million Line Problem · Molly Rocket · 1:48:55
- USENIX ATC '21/OSDI '21 Joint Keynote Address-It's Time for Operating Systems to Rediscover Hardware · USENIX · 1:06:19
- The Fast Fourier Transform (FFT): Most Ingenious Algorithm Ever? · Reducible · 28:23
- Jim Keller: Moore's Law, Microprocessors, and First Principles | Lex Fridman Podcast #70 · Lex Fridman · 1:34:43
- 34C3 - The Ultimate Apollo Guidance Computer Talk · media.ccc.de · 1:01:41
- Jim Keller: Moore’s Law is Not Dead · UC Berkeley EECS · 1:04:53
- "Programming a 144-computer chip to minimize power" - Chuck Moore (2013) · Strange Loop Conference · 40:12