OsrsNeedsF2P@lemmy.ml to Programmer Humor · 1 day agoparseInt(5)lemmy.mlimagemessage-square63linkfedilinkarrow-up1465arrow-down15
arrow-up1460arrow-down1imageparseInt(5)lemmy.mlOsrsNeedsF2P@lemmy.ml to Programmer Humor · 1 day agomessage-square63linkfedilink
minus-squaredanda@lemmy.ziplinkfedilinkarrow-up100·1 day agoIt’s because parseInt is expecting a string, so the decimal gets converted to a string, and 0.0000005.toString() returns 5e-7.
minus-squareAnotherPenguinlinkfedilinkEnglisharrow-up4·14 hours agoMore like javascript L, even python would throw a TypeError for this example.
minus-squarespizzat2@lemm.eelinkfedilinkarrow-up31·edit-21 day agoAnd to further expand on that, if you do pass in a sting string, it handles it correctly. > parseInt('0.0000005') 0
minus-squareSpaceNoodle@lemmy.worldlinkfedilinkarrow-up16·edit-29 hours agoWhat if I pass in a Stewart Copeland?
It’s because parseInt is expecting a string, so the decimal gets converted to a string, and
0.0000005.toString()
returns5e-7
.Common Dynamic Typing L
More like javascript L, even python would throw a TypeError for this example.
And to further expand on that, if you do pass in a
stingstring, it handles it correctly.> parseInt('0.0000005') 0
What if I pass in a Stewart Copeland?
or a Honda civic
😆 I’ll be watching you…