Комментарии:
What?
ОтветитьMath.round()
ОтветитьI hate that I don't just understand but that I can feel this from personal experience...
Ответитьfelt the 2.9999999999999991 😭🙏
ОтветитьAgred
ОтветитьArray.prototype.sort() 💀
ОтветитьThat's just IEEE floats.
JS, Java, C++ whatever.
console.log(0.1+0.2)
0.30000000000000004
Why this issue??
ОтветитьIsn’t this should be 0.12?
ОтветитьWait I'm floated
ОтветитьPhp dev spotted 🤦
ОтветитьWhy are you even comparing float?
ОтветитьWhy not != like a float plus a float is obv going to be a float no need to make it be strictly equal to
ОтветитьSomehow I read it like:
0.1! + 0.2! == 0.3!
Not a js thing, its global
ОтветитьUse ints instead of floats.
Ответить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()
ОтветитьTrue
ОтветитьIt should be != no?
ОтветитьBro i thought it was 0.2!
ОтветитьNumber.toFixed(2)
Or however many decimal places are significant.
my stupid ass thought that was a factorial so i had to double check
ОтветитьThis is like a calculator giving you 10+12E or some shit when on the graph its clearly 0
ОтветитьWhat is this language? Mostly unequal writed as !=
ОтветитьWhy?
Ответитьtrue
Js😵💫
! == ?! Я знаю только ! =
Ответитьfor those wondering, that's the strict comparison operator (data types must be the same)....just missing the IF statement
Ответить😅
Ответить"Don't try to bend the spoon. Realize... there is no spoon" ahh moment
ОтветитьA programmer has a problem. They decide to use floating point numbers. Now they have 1.99999999991 problems.
ОтветитьIts just not possible.
Ответитьit has to be != not !==
ОтветитьTry use ~~
Ответить!=
Ответить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
False
Ответить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
Ответитьisnt this interpreted right to left? meaning this is equal 1.1
ОтветитьTrue
Ответить!yes = no
ОтветитьLooks familiar to the if statement in JavaScript...🤔
ОтветитьSirf 19 ,20 ka hi tu farak ha 😂
Ответить"911 what's your emergency?" "math isn't mathing in JavaScript"
ОтветитьAww man. And here i was thinking it was a concatenation meme.
ОтветитьAll languages except COBOL, and other languages with built-in decimal type.
Ответить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();
}
}
Math.abs((0.1 + 0.2) - 0.3) < Number.EPSILON
Ответить