Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Agreed. A closely related infelicity is that integer division in most languages (and indeed, on most CPUs that have an integer divide instruction) truncates toward zero. So 1 / 2 and -1 / 2 both evaluate to zero.

The `floor' operation -- that truncates toward negative infinity -- is a more useful primitive, and goes hand in hand with the modulo operation defined as you describe.



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

Search: