How big can a 64 bit unsigned integer be?

It is hard or impossible to detect by looking at a value.
The problem is the maximum value plus even only 1 is still/again a valid value; i.e. 0.

This is why most programmers avoid as much as possible, if it is actually a wrong value. For some applications, wrapping around is part of the logic and fine.

If you calculate e.g. c=a+b; (a, b, c being 64bit unsigned ints and a,b being worryingly close to max, or migth be) and want to find out whether the result is affected,
then check whether ((max - b) < a); with max being the appropriate compiler-provided symbol.

Do not calculate the maximum value yourself as 2^64-1, it will be implementation specific and platform specific. On top of that, it will contain the wraparound twice (2^64 being beyond max, probably 0; and subtracting 1 going via 0 back…). And that applies even if ^ is understood to be an appropriate version of “to the power of”.

Leave a Comment

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş