Why Every Computer Fails Basic Math

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 ต.ค. 2024

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

  • @-taz-
    @-taz- 4 หลายเดือนก่อน +43

    When I was your age (old man here!), we didn't even have a floating point unit. We had to emulate it (super slow) or buy a math co-processor. But since customers never had those, we just did integer math and then did a binary shift right to divide by 64 before drawing on the screen buffer in pixels. Quake was the first major game or product that depended on having a math unit built-in.

    • @catchwest.combypuneetgrover
      @catchwest.combypuneetgrover 4 หลายเดือนก่อน

      As far my guess goes such emulations are still very useful in creating processors or robotics or even gaming consoles where programming languages don't work.. however now overall it's a diversified sector with very few people capable of understanding the concepts, and if they didn't get aware about this fact, they will be fooled and pressurised resulting in failure to earn huge money, so be super over confident if you had solved complex programming, only rarest of rare can achieve that, and all this rumours of there are lots of programmers in competition, ai will replace programmers, only non programmers can believe these lies.

    • @abhishekpratap05
      @abhishekpratap05 4 หลายเดือนก่อน

      😱🤯

    • @takethat6927
      @takethat6927 4 หลายเดือนก่อน

      👌.. yay I won ! See I commented and reported other user, proves I am the programmer of youtube...

    • @funreviews1436
      @funreviews1436 4 หลายเดือนก่อน

      ​@@takethat6927ha ha yeah India have programmers and nothing is outsourced from West, and reason there is rarely any website mentioning programmer details or link on their website.. haha children here can only play law sports or laziest cricket and want to claim education..

  • @devopsjuan
    @devopsjuan 4 หลายเดือนก่อน +5

    The actual calculation from binary (110) to decimal (6) representation is (2^2)*1 + (2^1)*1 + (2^0)*0 = 4 + 2 + 0 = 6. Otherwise, great video 👍.

  • @BeCurieUs
    @BeCurieUs 4 หลายเดือนก่อน +9

    This is a solved problem for javascript programs...just use BigDecimal or a similar package. Never actually divide or multiply things if you can help it. We ran into this problem in production where the backend would store values as a decimal, but we wanted to display them to the user as a percentage. Even just the trivial * / 100 will introduce rounding errors. I would strenuously implore you to use a math package that handles this for you.

  • @alexeyshaykov
    @alexeyshaykov 4 หลายเดือนก่อน

    To be honest, I didn't understand much, but it was exciting. Yes, keep recording such video on deep dive topics. Thanks man!

  • @metalbroga
    @metalbroga 4 หลายเดือนก่อน +1

    I've read about this once, but seeing that visual representation on the calculator was really good. Thanks for sharing.

  • @burtyful1
    @burtyful1 4 หลายเดือนก่อน +6

    Excellent explanation of a complex topic !!

  • @medamine44100
    @medamine44100 4 หลายเดือนก่อน +2

    Hi Kyle i'm gonna try out nerd you 😅,15:03 the largest number that can be represented in 32 bits is not 2 to the power of 32 ( because it needs 33 bits),. The largest number is 2 to the power of 32 minus 1.

  • @markmaples7215
    @markmaples7215 4 หลายเดือนก่อน

    Very helpful. Interesting to see how these problems were solved, to enable encoding into a binary format.

  • @BlazeShomida
    @BlazeShomida 4 หลายเดือนก่อน +1

    One trick I learned to count in binary, is you can use your fingers, think of each finger as a power of 2. So your first finger is 1, your second finger is 2, your first and second finger is 3, etc. Essentially you can count up to 31 on one hand and 1023 with two hands

  • @VincentYang024
    @VincentYang024 4 หลายเดือนก่อน

    Good explanation. I was refreshing the same thing yesterday as a very old interview question came to my head suddenly “ why do you use decimal for money?” I could not give an in-depth answer, if I can tell the precision issue in binary floating-point to interviewer , I might get that job many years ago😂

  • @kennethmortensen6990
    @kennethmortensen6990 4 หลายเดือนก่อน

    Good one, stuff like this is important.
    You could maybe add, that the larger the numbers you represent, the less precision you have. A good analogy is an elastic ruler: when you stretch it, the gaps between the marks get longer. So, for small numbers, it's more precise, but measuring a big number would create larger gaps between the marks, causing you to lose precision.

  • @SirMeowMeow
    @SirMeowMeow 4 หลายเดือนก่อน +1

    I'd argue that the base representation problem is not the right way to frame why software math is a problem. In languages like Racket adding 0.1 + 0.2 is fine. All number specs make a compromise between speed, accuracy, and space efficiency and floating point numbers will come with wonky behaviors like non-commutative addition. JS just happens to choose the IEEE 754 floating point as their default number type. As do many languages, but again, not all.
    There's no clean way to protect yourself from floating point wonkiness except to actually analyze the math you do in your software. Even OpenAI can become surprised by floating point behavior.

  • @Alcaatraz01
    @Alcaatraz01 4 หลายเดือนก่อน +2

    Great video and perfect length

  • @belkocik
    @belkocik 4 หลายเดือนก่อน

    Would love to see more videos like this where you explain how computer works.

  • @husseinsalim2398
    @husseinsalim2398 4 หลายเดือนก่อน +1

    I love and love your free courses for Next js and prisma

  • @BooksWeCanRead
    @BooksWeCanRead 4 หลายเดือนก่อน +1

    This was awesome! Would love more like this! 😊✨

  • @MFSln
    @MFSln 4 หลายเดือนก่อน +5

    2 the power of 0, or generally n to the power of 0 always gives 1.

    • @_Greenflag_
      @_Greenflag_ 4 หลายเดือนก่อน

      Yes, what a mistake!

    • @_Greenflag_
      @_Greenflag_ 4 หลายเดือนก่อน

      Yes, what a mistake!

  • @cherubin7th
    @cherubin7th 4 หลายเดือนก่อน +1

    This is just the problem with floating point number. Other data structures like "Decimal" (in some languages) don't have this issue. The reason why floating point as the default is only because it is supported by the cpu directly and culture.

    • @fabriziocapolini4349
      @fabriziocapolini4349 4 หลายเดือนก่อน

      Not exactly: repeating decimal numbers exist in decimal notation as well. The result of 1/3 cannot be fully represented in decimal just as 1/10 cannot be fully represented in binary. The cultural problem is actually that languages cater for our habit of using a base 10 notation instead of their native base 2 representation: if instead of adding tenths in that example we were adding sixteenth, we wouldn't have a rounding problem :-)

  • @stanislavdomanskyi3613
    @stanislavdomanskyi3613 4 หลายเดือนก่อน +21

    2 pow 0 is 1, isn't it?

    • @oskarkottom8365
      @oskarkottom8365 4 หลายเดือนก่อน

      Mistakes happen lol, but yeah it is 1

    • @oskarkottom8365
      @oskarkottom8365 4 หลายเดือนก่อน

      In the second example he says it right tho lol

    • @cheens5349
      @cheens5349 4 หลายเดือนก่อน +1

      literally my brain right now

    • @WebDevSimplified
      @WebDevSimplified  4 หลายเดือนก่อน +5

      It is 1. I think in the first example I was trying to say that in our particular case we have a 0 in the 2^0 place which gives us 0 since 0 * 1 is 0.

    • @oskarkottom8365
      @oskarkottom8365 4 หลายเดือนก่อน

      @@WebDevSimplified You got it right in the second example tho

  • @williamdrum9899
    @williamdrum9899 3 หลายเดือนก่อน

    Here's a better question: Why even have equality comparisons for floating point in an interpreted language that don't auto-correct for epsilon?

  • @corscheid
    @corscheid 4 หลายเดือนก่อน

    I remember learning about this in college. Binary is interesting. It's also good for web devs to think about this low level stuff at least sometimes. It's not just for C++ devs only ;D

  • @youmeetinfo
    @youmeetinfo 3 หลายเดือนก่อน

    did you calculate 2 to the power of 0, first to be 0, then to be 1?

  • @ZacharyDuvallT
    @ZacharyDuvallT 4 หลายเดือนก่อน

    Thanks, please do more like this!

  • @nufSaid_
    @nufSaid_ 4 หลายเดือนก่อน

    Hi guys. Are you guys still getting tech roles? Been applying for jobs but nothing yet. Any idea on how or where to get jobs?

  • @jamiesajdak7147
    @jamiesajdak7147 4 หลายเดือนก่อน

    Great video! More like this for sure!

  • @premsagar4438
    @premsagar4438 4 หลายเดือนก่อน

    What keyboard you use?

  • @Srabon444
    @Srabon444 4 หลายเดือนก่อน

    @WebDevSimplified Ah..., my university's second trimester kicked in. 🤭 Hey Kyle, make a video about React Compiler. I'm really looking forward to your in-depth video.

  • @okaniyoshiii9212
    @okaniyoshiii9212 4 หลายเดือนก่อน

    Super interesting ! I want more videos like this :D

  • @jarbyvid
    @jarbyvid 4 หลายเดือนก่อน +1

    The first bit is either 0 or 1 - not 2^0 which would always be 1

  • @AlexDanilin
    @AlexDanilin 4 หลายเดือนก่อน +6

    2^0 = 1

    • @gerkim3046
      @gerkim3046 4 หลายเดือนก่อน

      and then 0*(2^0)=0

  • @anonym6132
    @anonym6132 4 หลายเดือนก่อน

    well that's on point, just yesterday I added a line to my JavaScript to multiply sth with (140/173) .... mayyybe I should check if the calculation isn't too far off

  • @sy_filis
    @sy_filis 4 หลายเดือนก่อน

    You could mention `Number.EPSILON`.

  • @Denis_Victorious
    @Denis_Victorious 4 หลายเดือนก่อน +2

    Thanks to computer science, I got to know such nitty-gritty ^_^

  • @ahmadbenchakhtir5787
    @ahmadbenchakhtir5787 4 หลายเดือนก่อน

    I love this so much honestly...

  • @jerryknows7765
    @jerryknows7765 4 หลายเดือนก่อน

    More like this!

  • @gelzintvidaure
    @gelzintvidaure 4 หลายเดือนก่อน +1

    awesome !

  • @KnightYoshi
    @KnightYoshi 4 หลายเดือนก่อน

    "Computers get this wrong" - no the IEEE spec gets it wrong. Many languages that don't use the IEEE don't have this rounding error.

  • @singh.aadarsh
    @singh.aadarsh 4 หลายเดือนก่อน +1

    Amazing 🎉

  • @sruthikrishnakumar1904
    @sruthikrishnakumar1904 4 หลายเดือนก่อน +1

    I wondered why this video had very less likes and realised I'm early.

  • @cheens5349
    @cheens5349 4 หลายเดือนก่อน

    2^0 = 0?

  • @krateskim4169
    @krateskim4169 4 หลายเดือนก่อน

    i would like more low level concepts

  • @aysommer
    @aysommer 4 หลายเดือนก่อน

    Legendary meme, I guess

  • @mohitmohlia8420
    @mohitmohlia8420 4 หลายเดือนก่อน

    amazing ❤

  • @ChucklesMcGee780
    @ChucklesMcGee780 4 หลายเดือนก่อน

    iEEE754 - we meet again

  • @jasonjasonjasonjasonjason
    @jasonjasonjasonjasonjason 4 หลายเดือนก่อน

    1x1 = 2 there are no straight lines

  • @rishiraj2548
    @rishiraj2548 4 หลายเดือนก่อน

    👍

  • @RedblocktheII
    @RedblocktheII 4 หลายเดือนก่อน

    Fun fact:
    This is also why calculator lie to you and tell you the digits of pi are 3.141592654

    • @RedblocktheII
      @RedblocktheII 4 หลายเดือนก่อน

      (the ninth digit is wrong)

  • @johnnymnemonic1199
    @johnnymnemonic1199 4 หลายเดือนก่อน

    I ask for some more 👍

  • @kirandey95
    @kirandey95 4 หลายเดือนก่อน +1

    How to become web developer and get high pay?

    • @Oncopoda
      @Oncopoda 4 หลายเดือนก่อน +1

      Start by playing Candy Crush for 8 hrs a day.

  • @Brettm501
    @Brettm501 4 หลายเดือนก่อน +1

    1x1=2 lol

  • @suelingsusu1339
    @suelingsusu1339 4 หลายเดือนก่อน

    🙏🙏🙏🙏👏👏👏👏👏🌹🌹🌹🌹🌹🖖🖖🖖🖖🖖🖖

  • @ghotifish1838
    @ghotifish1838 4 หลายเดือนก่อน

    Computers can add 0.25+0.5 better lol

  • @_OKEANOUS_
    @_OKEANOUS_ 4 หลายเดือนก่อน +3

    AI has significantly made coding ridiculously easy

    • @BDKing-hh7pk
      @BDKing-hh7pk 4 หลายเดือนก่อน

      Only those which solved by someone else already. If you give a unique problem like nextjs 14 or a super brand new tech it will struggle and sometime cant solve at all.

  • @risitas5874
    @risitas5874 4 หลายเดือนก่อน

    first!!!

  • @WebDevwithTed
    @WebDevwithTed หลายเดือนก่อน

    Basic math💩

  • @amixengineer
    @amixengineer 4 หลายเดือนก่อน

    thanks, nice explanation but th-cam.com/video/qTXwRSksJPg/w-d-xo.html would be 7 since 2^0 equals 1.

  • @AdolfRizzler41
    @AdolfRizzler41 4 หลายเดือนก่อน +4

    Javascript is just like a women you cant trust those