My guess is that the sprintf is not handling the 64-bt datatype. %ld means long not long long.
To print, I see you have 2 options:
- write your own routine to print the long long value
- convert to double and print using sprintf
- print out in hex, first the upper 32-bits, then the lower 32.
I hope that helps.