Why Binary Systems HATE Division

preview_player
Показать описание
Why computers can't compute 0.1*0.1 or 0.1+0.2 properly. 0.1*0.1 is actually unsolvable by computers because it is impossible for them to define 0.1. Computers will define 0.1 as slightly more or slightly less the the actual 0.1 value. So if you want to print 0.1*0.1, this will result 0.010000000000000002 because this is an approximation. So maybe computers are not really good at math after all...

This is the more complex answer: "Not all floating point numbers are exactly representable on a finite machine. Neither 0.1 nor 0.2 are exactly representable in binary floating point. And nor is 0.3. A number is exactly representable if it is of the form a/b where a and b are an integers and b is a power of 2. Obviously, the data type needs to have a large enough significant to store the number also." - David Heffernan. Alternative title: Computers can't solve this, heres why. Computers sucks at maths.

CREDIT
This video was inspired by Fireship's Youtube Short. @Fireship

LINKS

COURSES

MISSION
Our mission at Flutter Mapp (Flutter Mobile App) is to help purpose driven Flutter developers go full-time doing what they love and making an impact through coding. We achieve this with useful Flutter tips and straight to the point Flutter videos.

RECOMMENDED

DISCORD

SOCIAL MEDIA:

CONTACT

#FlutterMapp
#python
#java
Рекомендации по теме
Комментарии
Автор

So why does a calculator works? Can you explain?

MineroCS
Автор

premise is wrong but rest is correct. there are plenty of libraries that can help you with division etc. Also there is a field named symbolic computatioj. but yeah, binary representation of some numbers are not feasable.

fatihsonmez
Автор

It's not really even a fault, it's just a consequence of a system that's been designed with certain trade-offs in mind, that system is the IEEE 754 floating-point number specification. A straightforward way to understand it is a compression algorithm. We're compressing all of those numbers into the very finite space of a certain number of binary bits. If we have to say 16 bits available to store numbers that mean we can express at very best 65536 different numbers. In reality, we can't even manage all of those numbers. The IEEE 754 tries to capture many of those numbers as possible in this system while keeping things sensible. But no matter how many bits, there will always be gaps because we simply don't have an infinite amount of space. What you have in the end with this system is a single number format that allows you to express very big things and the very tiny things in the sub integer precision.

mogaclub
Автор

It all depends on the data type. It seems you're using a floating point datatype which internally uses base 2. But most languages / libraries also come with a decimal data type which calculates in base 10 - for example, there's Decimal in Python and PostgreSQL, and BigDecimal in Java and C#. So it's wrong that computers "CAN'T" solve this, it's just that you're using the wrong tool, which is optimized for speed and hardware acceleration. Here's the example in Python:

>>> from decimal import *
>>> Decimal('0.1')*Decimal('0.1')
Decimal('0.01')

Actually, most financial calculations use decimal data types, as they need to calculate in base 10 to correctly implement the rules given by law.

There's also plenty of libraries to calculate with exact fractions, or even symbolic calculation (e. G. MatLab).

MarkusSchaber
Автор

Really good and informative video we need more content like this

shivanshmishra
Автор

Uhm great but I really thought you would go deeper into how binary works and how we represent floating point numbers turing machines and shit as well. I really enjoyed the pizza 🍕 explanation really well btw it wasn't perfect but conveyed the point amazingly well.

TechBuddy_
Автор

I've known this for decades but this explanation was fun and I'll share it with new hires every time they face the first float error xD.

unixtreme
Автор

Still confusdd after such a good explanation. Pls help.

abdulwahabkhan
Автор

Can you make a video about how to use a text editor with firebase please?

mustafahadi
Автор

I need video editing tips sir we need another channel

AyushPanditofficial
Автор

Raku programming language (former Perl 6) gets it right every single time (and many other).

freedom_aint_free
Автор

Can you please do firebase flutterfire support demo project

bashafaris
Автор

we need more amazing videos like this 🔥

Amandeep-kqbz
Автор

this one was cool, but you seem to love pizza a lot. You use Pizza as an example everywhere 🤣🤣🤣. Here you go some Pizza for you🍕🍕🍕🍕

md.ismailalamkhan
Автор

There is decimal arithmetics, you know. Once upon the time _all_ computers had instructions for that, nowadays, if they don't, it is emulated in software. Also arbitrary precision, arbitrary base arithmetic.
This video is far too simplistic.

bazoo