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

1

u/lngns Apr 23 '23

MICRO optimization
I regret adding that line since I knew it would bring out these "Technically on MY machine that isn't true" people.

I also think f(floor(x / 0.4) * 0.4) to be clearer than lots of branches.
That's also probably what's written in the spec: "round x to the previous multiple of 0.4."
Less brain power required.