• ### Popular Now

• 13
• 27
• 9
• 9
• 20

#### Archived

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

# mod division improvments

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

## 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 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 on other sites
not even using asm ?

##### 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