Follow

javascript quiz 

is `-(a + b)` always the same value as `-a + -b`?

· · Web · 2 · 0 · 0

javascript quiz qualification 

assume `a` and `b` are integers, numbers, and that `a + b` is less than `Number.MAX_SAFE_INTEGER`; this isn’t a gotcha where `a` and `b` are strings and i’m not talking about rounding errors here

re: javascript quiz answer 

@Lady is this because of floating point arithmetic

re: javascript quiz answer 

@aescling technically

re: javascript quiz answer 

@aescling (by which i mean BigInt does not have this quality)

counterexample re: javascript quiz 

@Lady a = -b

counterexample re: javascript quiz 

@Lady would not have known this before hehe

counterexample re: javascript quiz 

@alyssa yeah i was trying to figure out if `$ + 0` was the fastest and easiest way to coerce `$` to never have negative zero (it is) and then i thought about it some more

Sign in to participate in the conversation
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.