this post was submitted on 17 May 2025
55 points (93.7% liked)

Programmer Humor

35694 readers
452 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
top 10 comments
sorted by: hot top controversial new old
[–] [email protected] 1 points 1 hour ago

Moot! Those ALL fail code review!

[–] [email protected] 22 points 16 hours ago (1 children)

Definitionally in IEEE floating point, NaN is not equal to anything, including itself. The only real abomination here is B:

> Math.min()
Infinity
> Math.max()
-Infinity
> 
[–] [email protected] 12 points 14 hours ago

I mean, B does make some amount of sense, if you realize that it's supposed to give you the maximum among the parameters (so you'd normally call it as Math.max(5, 3) === 5).

Well, and you can call that with zero parameters, because you can spread an array into it, which might have zero length. And then given these conditions, and if you don't want to throw an error, then -Infinity is kind of the least bad remaining option, as it's likely to generally work with the rest of your logic.

[–] [email protected] 3 points 10 hours ago

@yogthos i afraid of (0 == '') :blob_grinning_sweat:

[–] [email protected] 6 points 14 hours ago (2 children)
[–] [email protected] 1 points 1 hour ago

Just because it's not a number, doesn't mean it's the same not number. But what if it is? 🙃

[–] [email protected] 2 points 14 hours ago
[–] lowleveldata 3 points 12 hours ago

A && B && C && D

[–] [email protected] 2 points 16 hours ago (1 children)

It can't be anything other than B, right?

[–] [email protected] 5 points 16 hours ago