-2

A hashing function outputs an integer that is 256 bits long... so why not store it as such?

0

uint256 is usually used for numbers on which you'd like to perform arithmetic operations like +, -, *, /, etc.

A hash is almost never used like that. You almost never want to multiply a hash by 7. From that perspective it makes sense that it would have a different type.

If you call a hash an integer, you might as well call every piece of data an integer: pictures, strings, pdf documents, hashes, ... all integers because they all consist of bits. Maybe we should use integral data types for all of them.

  • I disagree that you would never use arithmetic operations on it, and in that way it is unlike strings. For example, adding the output of 5 hash functions increases the range of outputs and shifts the distribution, which is both useful and not uncommon. – luca590 Jul 1 '18 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.