delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/11/06:56:57

Message-Id: <3.0.5.32.19990809232331.007a9bc0@200.252.238.1>
X-Sender: thiagofga AT 200 DOT 252 DOT 238 DOT 1
X-Mailer: QUALCOMM Windows Eudora Light Version 3.0.5 (32)
Date: Mon, 09 Aug 1999 23:23:31 -0300
To: djgpp AT delorie DOT com
From: "Thiago F.G. Albuquerque" <thiagofga AT ambr DOT com DOT br>
Subject: uclock() and Integer
Mime-Version: 1.0
Reply-To: djgpp AT delorie DOT com

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019