Floating Point Fuzziness #coding #programming #javascript #python

Floating Point Fuzziness #coding #programming #javascript #python

CodeVenture

3 месяца назад

124,289 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@mk-ultra.1920
@mk-ultra.1920 - 26.02.2025 13:45

What?

Ответить
@nics51
@nics51 - 26.02.2025 15:13

Math.round()

Ответить
@Robin93k
@Robin93k - 26.02.2025 17:15

I hate that I don't just understand but that I can feel this from personal experience...

Ответить
@P0l15h-C0w
@P0l15h-C0w - 26.02.2025 17:21

felt the 2.9999999999999991 😭🙏

Ответить
@ranvirsingh6006
@ranvirsingh6006 - 26.02.2025 17:26

Agred

Ответить
@desmondwilson3416
@desmondwilson3416 - 26.02.2025 18:00

Array.prototype.sort() 💀

Ответить
@pauldraper1736
@pauldraper1736 - 26.02.2025 18:29

That's just IEEE floats.

JS, Java, C++ whatever.

Ответить
@shafaathussain7166
@shafaathussain7166 - 26.02.2025 20:43

console.log(0.1+0.2)
0.30000000000000004

Ответить
@MPVijay-nq7dy
@MPVijay-nq7dy - 26.02.2025 22:03

Why this issue??

Ответить
@Winniex6489
@Winniex6489 - 26.02.2025 22:31

Isn’t this should be 0.12?

Ответить
@FishbedMyBeloved
@FishbedMyBeloved - 26.02.2025 23:07

Wait I'm floated

Ответить
@chernobylfx2379
@chernobylfx2379 - 26.02.2025 23:13

Php dev spotted 🤦

Ответить
@Logicatube
@Logicatube - 26.02.2025 23:16

Why are you even comparing float?

Ответить
@likrecelineation
@likrecelineation - 26.02.2025 23:26

Why not != like a float plus a float is obv going to be a float no need to make it be strictly equal to

Ответить
@johnGalt2025
@johnGalt2025 - 26.02.2025 23:33

Somehow I read it like:
0.1! + 0.2! == 0.3!

Ответить
@hmehrzad3962
@hmehrzad3962 - 26.02.2025 23:41

Not a js thing, its global

Ответить
@tr4nce206
@tr4nce206 - 27.02.2025 08:09

Use ints instead of floats.

Ответить
@michaelc.4321
@michaelc.4321 - 27.02.2025 08:12

This is just a problem with floating point numbers in general. Remember to tolerance your equality checks. C++ has a useful tool for this in the form of std::Numeric_Limits<type>::epsilon()

Ответить
@utkarshmahto7615
@utkarshmahto7615 - 27.02.2025 08:51

True

Ответить
@atalamcom
@atalamcom - 27.02.2025 08:55

It should be != no?

Ответить
@TheFinalBossRudy
@TheFinalBossRudy - 27.02.2025 11:24

Bro i thought it was 0.2!

Ответить
@exisfohdr3904
@exisfohdr3904 - 27.02.2025 16:00

Number.toFixed(2)

Or however many decimal places are significant.

Ответить
@vladyslavkryvoruchko
@vladyslavkryvoruchko - 27.02.2025 16:39

my stupid ass thought that was a factorial so i had to double check

Ответить
@DIGIZITE
@DIGIZITE - 28.02.2025 04:52

This is like a calculator giving you 10+12E or some shit when on the graph its clearly 0

Ответить
@Nexus-o9f
@Nexus-o9f - 28.02.2025 11:06

What is this language? Mostly unequal writed as !=

Ответить
@Yalovayahznepomnimena
@Yalovayahznepomnimena - 28.02.2025 12:33

Why?

Ответить
@Sasuke-0x1
@Sasuke-0x1 - 28.02.2025 19:12

true

Js😵‍💫

Ответить
@LoL_MeMeS_original
@LoL_MeMeS_original - 28.02.2025 20:15

! == ?! Я знаю только ! =

Ответить
@poprivest4715
@poprivest4715 - 28.02.2025 21:06

for those wondering, that's the strict comparison operator (data types must be the same)....just missing the IF statement

Ответить
@Afshinfallahnejad
@Afshinfallahnejad - 28.02.2025 23:50

😅

Ответить
@stone_apes
@stone_apes - 01.03.2025 04:43

"Don't try to bend the spoon. Realize... there is no spoon" ahh moment

Ответить
@gaimerI17
@gaimerI17 - 01.03.2025 22:18

A programmer has a problem. They decide to use floating point numbers. Now they have 1.99999999991 problems.

Ответить
@HoneyBunny-o3q
@HoneyBunny-o3q - 01.03.2025 22:54

Its just not possible.

Ответить
@gummimauer
@gummimauer - 02.03.2025 03:55

it has to be != not !==

Ответить
@havrilyk4115
@havrilyk4115 - 02.03.2025 04:02

Try use ~~

Ответить
@리븐꿀벅지
@리븐꿀벅지 - 02.03.2025 10:16

!=

Ответить
@diogomiguel2409
@diogomiguel2409 - 02.03.2025 14:33

It's because to a computer 1 is not really 1.
It's 1.0000000000000001 or something.
So when you say 1 == 1 they might say it's false in some programming languages

Ответить
@MaksimLeonenko
@MaksimLeonenko - 03.03.2025 07:47

False

Ответить
@Bobodita-kun
@Bobodita-kun - 03.03.2025 11:26

As someone learning js and html and css more moving from other languages and tools I first ran into this the other day and it bothered me a lot. I made it round my number * 10 and divide by 10 to make sure it doesn’t happen again, but it probably still does and I’m just not gonna log it and I’ll sleep fine as long as I never do

Ответить
@FalB27
@FalB27 - 04.03.2025 10:43

isnt this interpreted right to left? meaning this is equal 1.1

Ответить
@Rravsaheb2121
@Rravsaheb2121 - 07.03.2025 10:02

True

Ответить
@Nabi_mohammed
@Nabi_mohammed - 07.03.2025 15:44

!yes = no

Ответить
@itzgametimevip1111
@itzgametimevip1111 - 08.03.2025 21:14

Looks familiar to the if statement in JavaScript...🤔

Ответить
@shandeveloper621
@shandeveloper621 - 14.03.2025 23:04

Sirf 19 ,20 ka hi tu farak ha 😂

Ответить
@Displxyz
@Displxyz - 16.03.2025 13:14

"911 what's your emergency?" "math isn't mathing in JavaScript"

Ответить
@shadowlynxv6082
@shadowlynxv6082 - 23.03.2025 15:42

Aww man. And here i was thinking it was a concatenation meme.

Ответить
@dfsdgmythtrvvbyrtr
@dfsdgmythtrvvbyrtr - 10.04.2025 17:44

All languages except COBOL, and other languages with built-in decimal type.

Ответить
@Neonsise
@Neonsise - 15.04.2025 10:03

I always code it like

Float apple = 0.1;
Float banana = 0.2;
float potato = 0.3;

Void THE_MATH(){
If apple + banana != Potato{
Kill_myself();
}
}

Ответить
@Nivek389
@Nivek389 - 16.05.2025 03:20

Math.abs((0.1 + 0.2) - 0.3) < Number.EPSILON

Ответить