Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Does sse2 use binary operators % and /?

How would i write:
C++
int x=k%p; // eg 9/4 is equal to 1 and not 2.25(modulus operator) 
int y=a/b; // eg 9/4 is equal to 2 and not 2.25 ?
Posted
Updated 23-Jul-10 5:47am
v2

Probably best to consult the Intel reference[^].
 
Share this answer
 
Comments
Kythen 23-Jul-10 14:00pm    
Your link is to the basic x86 integer division instruction, not an SIMD division instruction in MMX/SSE/etc. While I agree that it's best to consult the CPU reference docs, I'm not sure that pointing him to the basic x86 DIV instruction is nearly as helpful as pointing him to the SSE2 instruction set reference would be.
No, there are no explicit division or modulus instructions in SSE2. You only get multiplication and shift operations.

If you are dividing by a constant, you might be able to use "magic numbers" to multiply by the multiplicative inverse. If not, you can try Newton's method to find the multiplicative inverse.

These two links may be of some use:
http://www.gamedev.net/community/forums/topic.asp?topic_id=537139[^]
http://www.hackersdelight.org/divcMore.pdf[^]
 
Share this answer
 
v2
Comments
Richard MacCutchan 23-Jul-10 14:55pm    
Your comment above is noted; however, the point I was trying to make was that the OP could make an effort to search the documentation for himself.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900