3 ms·
Modern compilers do some variant of fast integer division by constants, but I think most use the "round-up" algorithm described in an earlier post in this serie
by simonster 12y ago
Modern compilers do some variant of fast integer division by constants, but I think most use the "round-up" algorithm described in an earlier post in this series (http://ridiculousfish.com/blog/posts/labor-of-division-episode-i.html http://ridiculousfish.com/blog/posts/labor-of-division-episo...) and a variety of other places and not the "round-down" algorithm described in this post when the multiplier is a bit too big. You'd know better than I, but it looks like this is the round-up algorithm: https://github.com/D-Programming-Language/dmd/blob/master/src/backend/divcoeff.c#L206-L208 https://github.com/D-Programming-Language/dmd/blob/master/sr...