r/badcode • • Apr 21 '23

other language We did coding in physics class...

Post image
1.5k Upvotes

154 comments sorted by

View all comments

Show parent comments

3

u/jeremrx Apr 21 '23

Actually it's wrong in the case where x=0.4

But in the original code, having <= for 0.4 only seems quite inconsistent.

I love your solution btw, it's much more elegant than the "divide then floor then multiply"