#Wraparound overflow as opposed to %

6 messages · Page 1 of 1 (latest)

hot panther
#

When multiplying two unsigned characters that overflows assignment to a third unsigned character wraparound overflow occurs. This emulates the modulo operation (%).

When producing the corresponding assembly the instructions are identical. Is it OK to assume wraparound overflow in niche situations? Does this prevent the expensive use of the modulo operator? What should one be aware of?

jovial berryBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

stuck narwhal
#

Unsigned integer types implement modulo arithmetic.

hot panther
#

so it's effectively identical?

stuck narwhal
#

It is exactly what's used.

hot panther
#

thanks, I wasn't aware of that. Don't usually program in c. Solved in lightning speed