this post was submitted on 05 Aug 2023
501 points (92.1% liked)

Programmer Humor

24317 readers
815 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] korstmos@kbin.social 47 points 2 years ago (2 children)

Doubles have a much higher max value than ints, so if the method were to convert all doubles to ints they would not work for double values above 2^31-1.

(It would work, but any value over 2^31-1 passed to such a function would get clamped to 2^31-1)

[–] parlaptie@feddit.de 4 points 2 years ago

But there's really no point in flooring a double outside of the range where integers can be represented accurately, is there.

[–] affiliate@lemmy.world 2 points 2 years ago (2 children)
[–] idunnololz@lemmy.world 6 points 2 years ago (1 children)
[–] affiliate@lemmy.world 3 points 2 years ago (1 children)

yeah that would be pretty effective. could also go to three just to be safe

[–] hariette@artemis.camp 2 points 2 years ago

Make it four, just to be even

[–] korstmos@kbin.social 2 points 2 years ago