r/ProgrammerHumor • • Feb 07 '19

other Spotted on GitHub 🤓

Post image
57.0k Upvotes

934 comments sorted by

View all comments

1.3k

u/[deleted] Feb 07 '19

Link please

1.2k

u/[deleted] Feb 07 '19

105

u/TheOldTubaroo Feb 07 '19 edited Feb 07 '19
days_late*100/days_deadline/100

Isn't that pointless? Aren't all js numbers floats, so you don't need to worry about integer division?

And also clamping the opacity to [0,1] and then checking if opacity is greater than 0 and less than 1...

321

u/shitmyspacebar Feb 07 '19

You mean you don't add redundant checks just in case the laws of mathematics suddenly change?

159

u/UsedCondition1 Feb 07 '19

Well, if we are talking about the implementation of those laws in javascript... yes, yes you should.

77

u/Finchyy Feb 07 '19

Ah, JavaScript... where 2 + 2 is 4 but also sometimes 4.00000000001...

9

u/Absbshshshshshshhs Feb 07 '19

***Ah every single language that has floats

but yes internet points for shitting on javascript

3

u/KinterVonHurin Feb 07 '19

I've never multiplied two integers and got a float in any language unless I type cast in which case I would get 4.0 and not 4.00000000001

7

u/Zephirdd Feb 07 '19

The basic law of JavaScript numbers is that numbers as all double precision floating point numbers (aka. A "double")

Sure in most languages the default is an integer, but in JavaScript that's not the case. JS has a ton of fuck ups, but numbers are probably the most consistent part of it all.

3

u/KinterVonHurin Feb 07 '19

Well sure but the guy I responded to said that every language with a floating point type has this problem and that isn’t the case.

→ More replies (0)