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

A compiler I use, based on lcc, did this automatically without even enabling optimizations.

The division is transformed into multiplication and a right shift.

I don't think your usual programmer must care about that with the modern compilers, but it is nice to know if you are implementing one or you are coding in asm.



Or if you're dealing with data that isn't compile-time constant, but can be expected to remain unchanged for the duration of something that needs to be optimized all the way.




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

Search: