Y
Hacker News
new
|
ask
|
show
|
jobs
by
krzat
3219 days ago
Why not `x / 16`?
2 comments
sheldor
3219 days ago
Integer division will give a rounded result instead of floor
link
sp332
3219 days ago
I think they're going for the ceiling here, not the floor. Truncation of positive values should be the same as a floor function.
link
kutkloon7
3218 days ago
Yes, I wrote the example. Then realized it was different and corrected only half of it.
link
jskkk
3219 days ago
Not in C..?
link
thechao
3219 days ago
(x + 15) / 16
link
jskkk
3219 days ago
Yes, which is more readable and would be compiled to the same thing
link