Floating Point Numbers - Computerphile

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 ม.ค. 2014
  • 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: • Triangles and Pixels
    The Trouble with Timezones: • The Problem with Time ...
    More from Tom Scott: / enyay and / tomscott
    / computerphile
    / computer_phile
    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: bit.ly/bradychannels

ความคิดเห็น • 825

  • @Daealis
    @Daealis 10 ปีที่แล้ว +3271

    I got 0.9999... Problems and floating point is one.

  • @MorreskiBear
    @MorreskiBear 8 ปีที่แล้ว +3690

    Explains weird results I got in BASIC programs 29.99999998 years ago!

  • @timothemalahieude5076
    @timothemalahieude5076 8 ปีที่แล้ว +2723

    I think this actually used to be a flaw in some banking systems, because programmers initially used floating-point numbers to store accounts money. And then someone took advantage of it by making a lot of transactions from 2 of his accounts, where each transaction made him win a tiny bit of money due to rounding. So in the long term he was able to "create" as much money as he wanted.

  • @InsaneMetalSoldier
    @InsaneMetalSoldier 8 ปีที่แล้ว +10177

    Everything is easier to understand if it's explained in british accent

  • @WarpRulez
    @WarpRulez 9 ปีที่แล้ว +731

    Small correction: You don't need a 64-bit computer to use 64-bit floating point numbers in hardware. For example on Intel processors 64-bit floating point has been supported since at least the 8087, which was a math co-processor for the 16-bit 8086 CPU. (The math co-processor has been integrated into the main CPU since the 80486, which was a 32-bit processor.)

  • @oatstralia
    @oatstralia 10 ปีที่แล้ว +559

    Another issue I've run across with floating point rounding errors is the fact that - for the same reasons outlined in the video - a comparative statement like "0.1 + 0.2 == 0.3" comes out false, and it can be super annoying to pick out where the error is coming from, especially if it's buried in some if statement. For things like currencies, I usually just deal with ints that represent the number of cents (e.g. $2.50 is represented as 250), and divide by 100 in the end... saves me the hair tearing.

  • @MMMowman23
    @MMMowman23 10 ปีที่แล้ว +1719

    This is why Minecraft 1.7.3 alpha has block errors after 2 million blocks away from spawn. Pretty cool.

  • @Creaform003
    @Creaform003 10 ปีที่แล้ว +770

    Minecraft stores entities as floating point's, when the world was infinite you could teleport something like 30,000km in any direction and see objects start to move and stutter about including the player.
    Once you hit 32 bit int overflow the world would become Swiss Cheese, and at the 64 bit int overflow, the world would collapse and crash.

  • @antivanti
    @antivanti 10 ปีที่แล้ว +439

    nought (nɔːt)
    (Mathematics) the digit 0; zero: used esp in counting or numbering
    For those who were wondering. I guess it has the advantage of being half the number of syllables as "zero".

    • @IceMetalPunk
      @IceMetalPunk 10 ปีที่แล้ว +143

      My calculus teacher in high school loved that word, mainly because when he'd have a subscript of 0, he'd use the variable y just to say, "Well, y-nought?"

  • @chaquator
    @chaquator 9 ปีที่แล้ว +735

    So is this why I got like 5.0000003 when I input 25 into my self-written square-root function?

  • @themodernshoe2466
    @themodernshoe2466 10 ปีที่แล้ว +490

    Can you PLEASE do more with Tom Scott? He's awesome!

  • @AtheniCuber
    @AtheniCuber 8 ปีที่แล้ว +3166

    american here, just hearing 'Not Not Not Not Not Not Not Not Not Not Not seven'

  • @wolverine9632
    @wolverine9632 6 ปีที่แล้ว +169

    I remember the first time I experienced this. I was writing a Pac-Man clone, and I set Pac-Man's speed to be 0.2, where 1.0 would be the distance from one dot to another. Everything worked fine until I started coding the wall collisions, where Pac-Man keeps going straight ahead until hitting a wall, causing him to stop. The code checked to see if Pac-Man's location was a whole integer value, like 3.0, and if it was it would figure out if a wall had been hit. When I tested it, though, Pac-Man went straight through the walls. If I changed the speed to 0.25, though, it worked exactly as expected. I was baffled for a few moments, and then it hit me. Computers don't store decimal values the way you might first expect.

  • @eisikater1584
    @eisikater1584 8 ปีที่แล้ว +74

    Do you remember the (in)famous Apple IIe 2 squared error? 2+2 yielded four, as it should have been, but 2^2 yielded somothing like 3.9999998, and floating point arithmetic was difficult on 8 bit computers anyway. I once even used a character array to emulate fifteen digits behind the comma, not anything I'd do nowadays, but it worked then.

  • @novarren
    @novarren 8 ปีที่แล้ว +34

    I've put up English closed captions for this, since I haven't seen anyone else do CCs for this video, which is weird.
    I think it still needs authorised before it shows up actually on the channel, though.

  • @kagi95
    @kagi95 9 ปีที่แล้ว +54

    This is great, I've finally understood what it means (and why) when people say "loses precision" when referring to floating points.

  • @JSRFFD2
    @JSRFFD2 8 ปีที่แล้ว +318

    OK, so why does the cheap pocket calculator show the correct answer? I thought they used floating point numbers too. Do they have electronics that do computation in decimal?

  • @plutoniumseller
    @plutoniumseller 10 ปีที่แล้ว +392

    ...that's why the point is floating. *sudden clarity moment*

  • @junofall
    @junofall 8 ปีที่แล้ว +596

    starting out programming and some bullshit turned out as 4.000000005 instead of 4 so i'm here now xD

  • @joemaffei
    @joemaffei 8 ปีที่แล้ว +130

    An even better example of floating point error is trying to add 1/5 and 4/5 in binary, which is similar to the example in the video about adding thirds:
    1/5 = 0.0011~
    4/5 = 0.1100~
    1/5 + 4/5 = 0.1111~

  • @BritchesBumble57
    @BritchesBumble57 9 ปีที่แล้ว +66

    and this is why you should never fuck with floating point numbers

  • @FhtagnCthulhu
    @FhtagnCthulhu 8 ปีที่แล้ว +395

    Please, anyone reading this, don't use float for finances. Its a mistake I see people do all the time, please just don't.

  • @mtveltri
    @mtveltri 5 ปีที่แล้ว +147

    I have a computer science degree from a top school, and yet nothing was ever explained nearly as well as this.
    I love this TH-cam channel. Absolutely brilliant explaination. Thank you!!

  • @etmax1
    @etmax1 8 ปีที่แล้ว +34

    Well I've been working with computers for some 35 years and while very early compilers used to do 32 bit FP (floating point) around 20 years ago some people got together and settled on standards for floating point on computers and soon after 80 bit FP became a standard even though the computers were only 16 or 32bit at the time. Basically the machine's register size (32bit etc. has nothing to do with the number size usable as a sub-program deals with it. Sure it won't be as time efficient, but that's not what was suggested here.

  • @superdau
    @superdau 10 ปีที่แล้ว +155

    You should have mentioned: never use a check for equality with floats. The chances are very high you will never match it.
    On the other hand I guess every programmer should make that mistake once. E. g. decrease a whole number by 0,1 until you reach zero. Be prepared for a never ending loop.

    • @MrShysterme
      @MrShysterme 10 ปีที่แล้ว +22

      Many compilers throw a warning when you try to compare floats.
      I am not a computer scientist, but instead learned to code for research purposes and fun.
      There are cases where you have to compare floating point numbers. When I do so, my trick is to come up with some acceptable tolerance around them or to convert to large integers by multiplying or dividing by scalars, rounding, taking ceiling or floor, etc. Basically, I massage into an integer that I can control somewhat or use less than or greater than but watch what I'm up to. I've had many programs not function properly because I did not take into account the behavior of floating point.
      Is there other techniques that are better that I'm missing? I'm mostly self taught and come up with workarounds on my own.

    • @tobortine
      @tobortine 10 ปีที่แล้ว +3

      Entirely agree plus there's no reason (that I know of) to use a float for a loop counter.

    • @ThisNameIsBanned
      @ThisNameIsBanned 10 ปีที่แล้ว +5

      Yea most compilers i used actual see the problem and pop a warning, in Eclipse you can even go as far as using CheckStyle to auto-correct your operations with float (so it will highlight the possible problems right away).
      Float is great for speed, but you have to do some hacks to get precision again.

  • @MatthewChaplain
    @MatthewChaplain 9 ปีที่แล้ว +6

    I love the way that all of the scrap paper for these series is clearly paper for a tractor-fed printer that's probably been in a box since the 80s.

  • @miss1epicness
    @miss1epicness 10 ปีที่แล้ว +21

    Tom Scott's videos strike me (a young CS student) as my favorite. They're really authentic with the "and this is the part where you, a young programmer, start to tear your hair out"--please keep them up, I'm really enjoying it!

  • @EebstertheGreat
    @EebstertheGreat 5 ปีที่แล้ว +146

    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.

  • @mountainhobo
    @mountainhobo 10 ปีที่แล้ว +4

    Ran into this 30 years ago, was working in finance and trying my hand at simple applications running fairly complex transactions over many years horizon. Was dumbfounded then. Took me while to learn what was going on. Thanks for the trip down the memory lane.

  • @Xonatron
    @Xonatron 8 ปีที่แล้ว +15

    the speed of light = 299,792,458 m/s

  • @airmanfair
    @airmanfair 9 ปีที่แล้ว +52

    Aren't floating point errors what they used in Office Space to ripoff Initech?

  • @paterfamiliasgeminusiv4623
    @paterfamiliasgeminusiv4623 6 ปีที่แล้ว +2

    I appreciate the fact that you get into the topic right at the first second. You don't see this in the world very often.

  • @Jenny_Digital
    @Jenny_Digital 10 ปีที่แล้ว

    Well done on explaining it so well! For a long time I thought it a sod and left it. I finally had to do it in PIC assembly and then after I'd struggled to victory I get told straightforwardly over a single video many years later.
    Keep up the excellent stuff!

  • @EZCarnivore
    @EZCarnivore 8 ปีที่แล้ว +642

    5 years as a programmer, and I finally understand floating point numbers =P

    • @EZCarnivore
      @EZCarnivore 8 ปีที่แล้ว +184

      I have a college education, they just never explained it in a way that I understood it!

    • @WillLorenzoCooper
      @WillLorenzoCooper 8 ปีที่แล้ว +142

      +エックザック True it's like you have one shot to learn in a lesson then it's gone. While on here, you can relearn on many videos if we don't quite understand.

  • @majinpe
    @majinpe 10 ปีที่แล้ว

    Tom Scott's talk is so interesting and easy to understand
    I love this guy

  • @tobortine
    @tobortine 10 ปีที่แล้ว +15

    An excellent explanation and a pleasure to watch.

  • @Zeuskabob1
    @Zeuskabob1 4 ปีที่แล้ว +37

    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.

  • @mc85eu
    @mc85eu 8 ปีที่แล้ว +8

    Exceptionally clear and engaging.
    You're obvioiusly clever, but are also able to break things down and be interesting.
    I learned a lot - and not just about floating point. Thank you.

  • @MenacingBanjo
    @MenacingBanjo 10 ปีที่แล้ว +6

    Wow! I had wondered for years why Microsoft Excel would always end up with weird figures that would just show up way out in the 15th-or-so decimal places of the returned values from SUM formulas. Now I know. Thank you!

  • @CoxTH
    @CoxTH 10 ปีที่แล้ว +57

    To come back to the 3d game example:
    In older versions of Minecraft there is a bug caused by floating point rounding errors. Because the game world is procedurally generated those errors cause errors is the world generation. They only become significant when one of the coordinates is at about +/- 12.5 million, but there the world generation changes significantly.

  • @imanabu5862
    @imanabu5862 4 ปีที่แล้ว

    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

  • @KoyasuNoBara
    @KoyasuNoBara 9 ปีที่แล้ว

    Thank you! I came across this problem in some homework recently. I stored a decimal number plus an incrementing number in the float variable that the teacher provided in his premade node, and started getting this problem.
    The variable was supposed to hold user input anyway*, and since the problem didn't show up when I did it that way, I didn't bother worrying about it. It did confuse the hell out of me, though, so I'm glad to find an explanation.
    *I got tired of doing the user input part while trying to test my Linked List, because it involved about six different questions to answer per node.

  • @Czeckie
    @Czeckie 10 ปีที่แล้ว +14

    Congratulations on Tom Scott! He seems like a great teacher, I enjoyed this video very much - it doesn't matter that i knew the stuff already

  • @nickgrossman2385
    @nickgrossman2385 10 ปีที่แล้ว

    this is a great video, I never really understood floating point numbers until now. good job!

  • @rodcunille4800
    @rodcunille4800 9 ปีที่แล้ว +2

    Before anything, great explanation!!!
    That is why supermarket's checkout's systems expresses the currencies in hundreds and not in decimals, at the end, your bill will be divided by 100 and you'll get your exact amount to pay

  • @Werevampiwolf
    @Werevampiwolf 4 ปีที่แล้ว +10

    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.

  • @swal593868
    @swal593868 8 ปีที่แล้ว

    Thank you. Just what I needed, trying to learn Java and was getting confused when it was appropriate to use the 'float' keyword. Love your definition of a float "standard notation for Base 2.

  • @jmbrjmbr2397
    @jmbrjmbr2397 2 ปีที่แล้ว

    Thanks to this channel for these videos, they are so valuable for me.

  • @RitchieFlick
    @RitchieFlick 10 ปีที่แล้ว

    Have been programming for a while now (self-taught, 5 years in school, 1 semester in university) and I wasn't even aware of this. I LIKE :)

  • @krishnasivakumar2479
    @krishnasivakumar2479 5 ปีที่แล้ว

    I'm loving this channel. It's heaven.

  • @LeBonkJordan
    @LeBonkJordan 9 หลายเดือนก่อน +3

    Jan Misali basically said (heavy paraphrasing here) "0.3" in floating point doesn't really represent exactly 0.3; it represents 0.3 _and_ every infinitely-many other real numbers that are close enough to 0.3 to be effectively indistinguishable to the format. Basically, every floating point number is actually a range of infinitely many real numbers.

  • @deantheobald1393
    @deantheobald1393 9 ปีที่แล้ว

    an important piece of information i needed to know, will definitely look here first for any other needs i have on this subject... thanks!

  • @salmanbukhari2008
    @salmanbukhari2008 5 ปีที่แล้ว

    This is beauty. Well presented and many thanks.

  • @StephenDahlke
    @StephenDahlke 10 ปีที่แล้ว +28

    Eagerly awaiting the follow-up video that talks about the actual storage and operation of these numbers. My Numerical Analysis course spent several lectures on it, and wrapping your head around storing a number like 123.456 in IEEE 64-bit floating point is about as much fun as dealing with time zones. :)

  • @cbbuntz
    @cbbuntz 10 ปีที่แล้ว +9

    Floating point is quite nice for audio. It means that very quiet passages have roughly as much accuracy as loud passages. It can also be annoying for audio too. If you want to add DC offset for some types of processing, the accuracy plummets (as I pointed out in another comment here).
    example:
    If you have a quiet passage and you do something like
    x = in + 1;
    out = x - 1;
    out will have much lower accuracy than in.

    • @midinerd
      @midinerd 10 ปีที่แล้ว

      Because we do not perceive loudness in a linear form, the amount of positions offered to 'louder' portions is significantly larger than those allocated to the 'quiet' portions, and thus it is easiest to tell the bit-depth of the recording by listening to the quietest passages, loudest.

    • @Moonteeth62
      @Moonteeth62 10 ปีที่แล้ว +1

      And yet they tend to use absolute values that scale to the DAC values. Like 8,12,16,24 bit PCM. In the end ALL codecs have to feed an digital to analog converter that is N number of bits. Is there an audio format that uses floating point values? I don't know of one, but that doesn't mean anything.

    • @cbbuntz
      @cbbuntz 10 ปีที่แล้ว +1

      Moonteeth62 Most DAWs process audio with floating point. That's why Nuendo sounded better ProTools years. It's also much easier to be "sloppy" with floating point. You don't have to worry about clipping at all; With 32 bit float, you essentially have a scalable 24 bit PCM. However, I don't know of any modern floating point ADCs or DACs. There were some in early digital years to squeeze the most out of 12 bits and that sort of thing. Converters on early AMS and EMT gear from the late 70's early 80's were that way.
      Our senses are generally logarithmic loudness, brightness, skin pressure. Interestingly they're have been studies that indicate that tribes without civilized culture contact often have a logarithmic perception of numbers, as in they would "count" (so to speak) in exponents. 1 2 4 8 16 etc It makes sense to me though. If you have a million dollars, you don't care about 10 bucks. If you've got 40 bucks, you care about 10 bucks.

  • @0pyrophosphate0
    @0pyrophosphate0 10 ปีที่แล้ว

    This actually cleared up FP logic for me a lot. Thanks for that.

  • @jgcooper
    @jgcooper 10 ปีที่แล้ว +1

    it took me a long while, but i just noticed that the "/" was added at the end. awesome!

  • @RMoribayashi
    @RMoribayashi 9 ปีที่แล้ว +1

    My old HP-25c and 15c had Engineering notation. It was Scientific notation but the exponent always a multiple of 3 with up to three digits left of the decimal point. Getting your answers formatted 823.45x10⁻⁶ instead of 8.2345x10⁻⁴ made working with the Metric system effortless, absolutely brilliant.

  • @thecassman
    @thecassman 10 ปีที่แล้ว +10

    Fantastic explanation! Not heard it explained anywhere this clearly before and it's a great way to explain it. Keep these videos going Brady / Sean!
    As somebody who programmed for a payroll firm for 5 years, and now program for a credit risk firm - i totally appreciate the benefits of using decimal types!

  • @marko.rankovic
    @marko.rankovic 9 ปีที่แล้ว +2

    In Python, doing the 0.1 + 0.2 gave me 0.3000000... Then the last digit was 4.. This lesson helped me understand the situation :)

  • @SerpentStare
    @SerpentStare 9 ปีที่แล้ว +6

    Tom is very passionate about his numbers being correct. Some of his explanations of these errors almost sound as though the numbers have personally offended him.
    I find it rather charming.

  • @frollard
    @frollard 10 ปีที่แล้ว +1

    This primer now makes it all make sense.
    I've written a few programs where floats were required and they always pooped the bed somehow - to solve it I was doing type conversions to to integer math, then converting back...such a pain!

  • @Tulanir1
    @Tulanir1 10 ปีที่แล้ว +264

    If you type
    0.1 + 0.2
    into the python 3.4.1 shell you get
    0.30000000000000004
    But if you type
    1/3 + 1/3 + 1/3
    you get 1.0

  • @veloxsouth
    @veloxsouth 10 ปีที่แล้ว +29

    I would have loved to see more about the reserved cases of the floating point standard such as NaN, as well as some more on the topic of normalization. Hope there's more to this in some "extra bits"

  • @Wilc0
    @Wilc0 10 ปีที่แล้ว

    Tom, I really hope there are a lot more videos coming from you, I /love/ the way you talk! Maybe an idea for a future topic, the differences and down/upsides to all the different coding languages?

  • @Kd8OUR
    @Kd8OUR 10 ปีที่แล้ว +1

    You guys provide a far better lesson than anything I got in school.

  • @ivokroon1099
    @ivokroon1099 10 ปีที่แล้ว

    He says that the last didgit is not a problem, but once I tried to make a timer which kept adding 0.1 to itself, and when it reached a number (for example 3), it would activate another script. I did never activate because of those floating point numbers. Thanks for the explonation, computerphile!!!

  • @TechLaboratories
    @TechLaboratories 10 ปีที่แล้ว

    Thank you for what's probably the best explanation of floating point arithmetic that now exists! It's easy from this starting point to extrapolate into understanding floating point operations (FLOPs), and half (16bit), single (32 bit), and double (64bit) precision floating point numbers! Thanks Tom!

  • @TheyZebra
    @TheyZebra 7 ปีที่แล้ว

    Awesome as usual! Thanks for the knowledge. Subscribed.

  • @Frasenius9
    @Frasenius9 10 ปีที่แล้ว

    Yay for more of Tom Scott!

  • @coolboyrocx
    @coolboyrocx 10 ปีที่แล้ว

    I already understood this concept but I thought it was a really good explanation regardless. Some tricky things in here to get your head around initially so hopefully people find it useful!

  • @marcuswilliams3455
    @marcuswilliams3455 2 ปีที่แล้ว

    Very excellent explaining of Floating Point Numbers. Now it be great to explain about Decimal floating-point (DFP) aka IEEE 754-2008. As per financial transactions, people often balk at the one language which utilize BCD numbers for representing currency.

  • @mikelipsey8837
    @mikelipsey8837 10 ปีที่แล้ว +16

    This guy is a very good teacher.

  • @Patman128
    @Patman128 10 ปีที่แล้ว +2

    New languages (like Clojure) are starting to include fractions as a data type. If the numerator and denominator are arbitrary precision (integers that scale as necessary) then you can represent and do operations on any rational number with no error.

    • @DrMcCoy
      @DrMcCoy 10 ปีที่แล้ว

      Sure; just keep in mind that this introduces both memory and computational overhead. :)

  • @cosmemiralles1295
    @cosmemiralles1295 10 ปีที่แล้ว +1

    Finally, I start to understand what the floating point is!!!

  • @at-excel
    @at-excel 6 ปีที่แล้ว

    Thanks a lot for your explanation! Floating Point Numbers are a very big problem in spreadsheet calculations most People are not aware of. If you do a lookup or if-function the normal user expects, that his numbers are correct and not smaller or bigger. I allways use to round a value to cut the error off.

  • @ThePhiSci
    @ThePhiSci 10 ปีที่แล้ว

    I watch Computerphime's videos for this guy.

  • @RachelMant
    @RachelMant 6 ปีที่แล้ว +3

    Would be fantastic to see a video done on Fixed Point, which is the other way to solve the Floating Point accuracy issues for some small length of numbers, especially as you can store the decimal component as an integer and do some clever maths computing the overflow quantity back into the integer component. This is actually how programs like Excel solve the problem when you click the Currency button.

  • @nlgatewood
    @nlgatewood 10 ปีที่แล้ว +3

    I run into this problem all the time at work...I deal a lot with currency. great explanation

  • @nO_d3N1AL
    @nO_d3N1AL 10 ปีที่แล้ว

    Wow, didn't know there was so much to floating point numbers. Nice video

  • @BooBaddyBig
    @BooBaddyBig 10 ปีที่แล้ว +17

    Actually, in graphics it's also a problem, even being off by a fraction of a pixel can give a visible dust of gaps between surfaces.
    Careful rounding usually helps with floating point issues.

    • @murphy54000
      @murphy54000 10 ปีที่แล้ว +4

      Uhm. Pixels can't move, and there are less than 3000 tall/long on most screens. I fail to see how it could make a difference.

    • @BooBaddyBig
      @BooBaddyBig 10 ปีที่แล้ว +7

      For example in 3D graphics you also have rotation, translation and perspective transformations and they can individually or in combination put the edges of surfaces right either side of the centre of the pixel, so the point used for the pixel isn't touching either surface.

    • @murphy54000
      @murphy54000 10 ปีที่แล้ว +2

      BooBaddyBig Well I don't make graphics, so I'm going to say that it still doesn't really make sense, but I trust what you say regardless.

  • @Goodwithwood69
    @Goodwithwood69 8 ปีที่แล้ว +2

    Bloody hell! A video I understood right to the end! I'm usually lost two thirds of the way through on Braidy's videos,

  • @cfhay
    @cfhay 10 ปีที่แล้ว +17

    What I missed in the video is, the explanation how can the calculator show 0.1 + 0.2 as 0.3 still, when it uses floating point numbers. The calculator stores more precision than it shows on the screen, and the leftover digits are used for rounding, showing most of the stable calculations without error. This is important, because programmers needs to be aware of these errors, how to handle them, what error is tolerable, and what precision they need to keep up that requirement.

  • @johncampbell4389
    @johncampbell4389 4 ปีที่แล้ว +10

    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.

  • @Adiy.
    @Adiy. 2 ปีที่แล้ว +1

    Excellent video, Really Helped me!

  • @AlexVineyard
    @AlexVineyard 8 ปีที่แล้ว +32

    Thank you Sir Dude, I finally understand!

  • @devingreenfield8047
    @devingreenfield8047 6 ปีที่แล้ว

    you make so much more sense than my numerical methods prof, Thank you!

  • @samanthabayley2194
    @samanthabayley2194 6 ปีที่แล้ว

    This finally explains strange results in a program I wrote for first year uni. The program was meant to calculate change in the fewest possible coins but whenever I had 10c left it would always give two 5c coins, for the life of me I couldn't figure out why now I know. It also used to happen with the train ticket machines so at least I'm not alone in making that error.

  • @oO_ox_O
    @oO_ox_O 10 ปีที่แล้ว +4

    Could do a continuation where NaN and all the other fun stuff from IEEE 754 are explained and while at it maybe also talk about the different rounding modes and encodings of negative numbers.

  • @TheWeepingCorpse
    @TheWeepingCorpse 10 ปีที่แล้ว

    Loved learning how to program the FPU in assembler years back, I now use SIMD in my game engine.

  • @TheSam1902
    @TheSam1902 7 ปีที่แล้ว

    What a brilliant video, thank you, I wasn't aware of this problem and I'll think about it next time I deal with things like currency etc ^^

  • @mxkep
    @mxkep 8 ปีที่แล้ว

    I never thought floating point could be described in such an interesting way!

  • @rileystokes6924
    @rileystokes6924 6 ปีที่แล้ว

    Nice video, very well explained.

  • @ltcameron1
    @ltcameron1 6 ปีที่แล้ว

    Great video. Very many thanks. Makes floating point so much easier to understand.Bonus that it's a young brit! Well done.

  • @ronaldlijs
    @ronaldlijs 10 ปีที่แล้ว

    Well explained, keep them up!

  • @torikenyon
    @torikenyon 7 ปีที่แล้ว

    I like how they add a / to to mark the end of the video

  • @PullerzCoD
    @PullerzCoD 10 ปีที่แล้ว +14

    Thats first maths process is gonna save me a lot of anguish

  • @leeannison5048
    @leeannison5048 6 ปีที่แล้ว +1

    This was very helpful, thank you.

  • @Valenminbari
    @Valenminbari 10 ปีที่แล้ว

    Thanks for this. This is really good.

  • @reubenandrews9043
    @reubenandrews9043 7 ปีที่แล้ว

    my teacher failed to teach me this with years, tom scott succeded in 10 minutes