You have two issues here, Antoine. 'Waveform timestamp' and 'Compute Waveform' are unsigned integers, so the result of'Waveform timestamp - Compute Waveform' will be unsigned as well. Where you might expect that result to produce a small negative number, the unsigned datatype of the result will actually interpret a very large positive number.
The second statement has an "order of operations" issue. The 'ulong64(Compute Waveform))/333ULL' division is being performed before the subtraction from 'ulong64(Waveform timestamp)'. You need more parentheses to fix the order of operations ... but then you will still have the problem with the fact that these integers are unsigned. Thus, the only way to get your '-1' answer, I think, is to run:
(long64(Waveform timestamp) - long64(Compute Waveform)) / 333
James Jones
ITT Technical Support
|