Jump to content
  • Advertisement
Sign in to follow this  
lokki

Commutative, associative, distributive properties of operations

This topic is 5460 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

Hi, Looking for a list of properties of different binary operations, also looking for equivalence between binary operations. Any good references for bitwise bool algebra tricks? for example (x & 0x7c00) - (y & 0x7c00) =? (x-y) & 0x7c00 (x >> 16) - (y >> 16) =? (x-y) >> 16 Thanks

Share this post


Link to post
Share on other sites
Advertisement
Same rules apply to bitwise ops as for boolean ops, only difference being that the bitwise applies the boolean ops to each bit rather than the whole value.

AND - Similar rules to multiplication
OR - Similar rules to addition
SHIFT - Exactly the same as integer multiplication or division by a power of 2, depending on the direction of the shift

As for your example, try them with pen and paper. The first one doesn't work, but the second one does. It's usually not a good idea to mix bitwise and numeric operations, especially when you could end up performing bitwise ops on a negative value (with the exception of SHIFT, since it behaves exactly like integer multiplication/division).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!