Message-ID: <37B19BD6.50E5@ns.sympatico.ca> From: Klaas Organization: N/A X-Mailer: Mozilla 3.04 (Win95; I) MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: uclock() and Integer References: <3 DOT 0 DOT 5 DOT 32 DOT 19990809232331 DOT 007a9bc0 AT 200 DOT 252 DOT 238 DOT 1> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 69 Date: Wed, 11 Aug 1999 12:50:46 -0300 NNTP-Posting-Host: 142.177.75.42 X-Trace: sapphire.mtt.net 934386620 142.177.75.42 (Wed, 11 Aug 1999 12:50:20 ADT) NNTP-Posting-Date: Wed, 11 Aug 1999 12:50:20 ADT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com 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 > #include > #include > #include > > 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