Mail Archives: djgpp/1999/08/12/06:24:27
Thiago F.G. Albuquerque wrote:
>
> Quoting libc's documentation,
>
> "(...) `printf' cannot print a value of type `uclock_t', even though
> it is an integer value, because it is a 64-bit integer."
>
> So I thought of using libg++'s Integer class to print this 64-bit integer
> and wrote this piece of code:
>
> #include <allegro.h>
> #include <time.h>
> #include <stdio.h>
> #include <integer.h>
>
> int main()
> {
> allegro_init();
> install_keyboard();
>
> uclock();
> Integer i;
>
> while(!key[KEY_ESC])
> {
> i = uclock();
> cout << i << endl;
> }
>
> return 0;
> }
>
> However, the first lines of output were:
>
> 25
> 2317
> 4860
> 7466
> 10050
> 12645
> 15236
> -47579
> -45450
> -42852
> -40260
> -37660
> -35064
> -32469
> -30044
> -27873
> -25200
> -22602
>
> Why is it printing negative values?
>
> Do you know another way of printing an uclock_t?
>
> ----------------------------
> Thiago
The value of a 64bit integer can be up to 1.84E19.
When you transpose this onto an int (though it seems as though you are
using a short) the top gets chopped off, and it can also set the "-" bit
of the variable.
A "long long unsigned" should be able to hold 64bits...
-Mike
- Raw text -