Archived

This topic is now archived and is closed to further replies.

mod division improvments

This topic is 5014 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

#define MOD(x,y) y & (x-1)
i found this some where but it is inaccurate does any one know how ot make a more accurate and faster MOD function?

Share this post


Link to post
Share on other sites
That function is accurate for powers of two only. Other than powers of two, there''s no general way to do modulus with a constant that''s faster than just using modulus.


"Sneftel is correct, if rather vulgar." --Flarelocke

Share this post


Link to post
Share on other sites
quote:
Original post by vaneger
not even using asm ?

ASM isn''t a magic bullet. It''s just a lower-level language. More or less the same machine language instructions will be generated by the compiler as would be written by you, anyway. The number of situations where the best way to optimize is to rewrite stuff in ASM is very, very small.


"Sneftel is correct, if rather vulgar." --Flarelocke

Share this post


Link to post
Share on other sites