For 1.: 9223372036854775807 already is the maximum value a uint64_t can hold. Regardless of what you add, the result that is cased by the overflow will be less than that maximum value.

For2.: You are shifting that over the last bit that off_t can holt. Since the bit is not 'rotated' back in, the result is '0', since no bits are set to '1' in that value.

Um, that's not UI64_MAX. 9223372036854775807 is 0x7FFFFFFFFFFFFFFF, whereas UI64_MAX is 0xFFFFFFFFFFFFFFFF aka 18446744073709551615. 0x7FFFFFFFFFFFFFFF is I64_MAX.

Um, sorry, missed that - it's also not 'LOW - 1', because that would be equal to 0x7FFFFFFFFFFFFFFE, the difference is actually 0x1000000000000000 or 1152921504606846976), which is equal to '0xFFFFFFFFFFFFFFFE' or in other words: "The overflow will result in a value that is 'UI64_MAX - value_you_add''', which is

Now I finally understand the bit level math behind this overflow ;) I am sure you might have explained in one of your comment but i just could not relate to it and I was digging more about bit arithmetic which i did many years back in undergrad ;)

0111 FFFFFFFFFFFFFF F
+ 1111 FFFFFFFFFFFFFF F
-----------------------------------------------
0111 FFFFFFFFFFFFFF E (this is indeed 7FFFFFFFFFFFFFFE ;) )

Ideally the sum should be 1 0111 FFFFFFFFFFFFFF 1110
but there is no way to store the overflowed 1 in the MSB and it gets ignored (since the max bits can be 64 in uint64)

Juneâ€™s Course of the Month is now available! Experts Exchangeâ€™s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membershipâ€”an extra way to sharpen your skills and increase training.

This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++.
The reason I built this class is to ease the pain of using XML files with C++, since there isâ€¦

Introduction
This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more â€¦

The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.