I am just wondering whether differences will stay correct through an overflow. As example, I am trying to use a windows high resolution timer with QueryPerformanceFrequency(&local).
The starting value of that counter is undefined. However, the interesting bit is only the difference from the starting point. So at the beginning you record the value, and then always look at the diff. Now if I can guarantee that the difference won’t be larger than a LARGE_INTEGER, is this sufficient?
Say e.g. one has 4 bits. That allows for 1…15. If the counter now starts at 14, and stops at 2, and I do 2 – 14, I should be getting 4, shouldn’t I? So I needn’t worry about an overflow as long the difference is smaller?
Thanks
Since you are using a Windows-specific structure, your problem is easier since it only needs to run on machines that support Windows. Windows requires twos-complement arithmetic, and twos-complement arithmetic behaves on overflow in the manner you expect (overflows are computed mod 2^n).