4 ms·
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 th
by sa46 3y 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 https://news.ycombinator.com/item?id=18409344
- sedatk 3y agoI don't understand that comment. How do you handle carry?