Hacker News new | ask | show | jobs
by sa46 915 days ago
Seems like a compiler should be able to convert division to shifts and subtractions.

> u8 divmod 58 can be reduced to a u8->u16 multiply, a right shift, and three conditional subtractions; that's not great, but on a modern CPU it's a afterthought compared to the quadratic loop over the input size.

Same topic from 2018: https://news.ycombinator.com/item?id=18409344

1 comments

I don't understand that comment. How do you handle carry?