Hacker News new | past | comments | ask | show | jobs | submit login

Maybe this is a stupid question, but wouldn't that always return true? (a/b)*b just cancels out the b right? Unless there is weird floating point stuff going on.



There's not floating point stuff going on, that's why it works. :)

a and b are ints, so a/b is truncated (rounded down) before applying *b.


It's integer maths. For example: a = 10, b = 3 10/3 = 3 3 * 3 = 9 9 != 10




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: