this post was submitted on 05 May 2025
493 points (98.8% liked)

Programmer Humor

23172 readers
1625 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
[–] [email protected] 100 points 6 days ago (2 children)

It's because parseInt is expecting a string, so the decimal gets converted to a string, and 0.0000005.toString() returns 5e-7.

[–] [email protected] 43 points 6 days ago (1 children)
[–] [email protected] 5 points 6 days ago

More like javascript L, even python would throw a TypeError for this example.

[–] [email protected] 31 points 6 days ago* (last edited 6 days ago) (1 children)

And to further expand on that, if you do pass in a ~~sting~~ string, it handles it correctly.

> parseInt('0.0000005')

0
[–] [email protected] 18 points 6 days ago* (last edited 5 days ago) (2 children)

What if I pass in a Stewart Copeland?

[–] [email protected] 9 points 6 days ago

😆 I'll be watching you...

[–] [email protected] 3 points 6 days ago

or a Honda civic