In what way(s) would be an overflow in an expression be desirable in the following cases:
- Calculating a hash value
- Calculating a check sum
?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
So long as you’re expecting that operations may overflow, and that the definition of what you’re trying to do allows for overflow (or possibly requires it as a result) it makes life a lot easier.
For instance, one algorithm for calculating a hash is:
For example:
Here, any of the calculations could overflow, but that’s okay – we’re not really interested in the magnitude of the number, just the aim that it’s likely to be different for different objects, but the same for equal ones.
Trying to do this without overflow is a pain – you could use XOR, but that has other downsides.