www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/05/16/10:23:53

Date: Sun, 16 May 1999 17:19:01 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Sean <sproctor AT enter DOT net>
cc: djgpp AT delorie DOT com
Subject: Re: uclock trouble
In-Reply-To: <373EBC8B.A6271397@enter.net>
Message-ID: <Pine.SUN.3.91.990516171327.20684C-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Sun, 16 May 1999, Sean wrote:

> Eli Zaretskii wrote:
> > First, please post a short test program that exhibits this behavior.
> 
> I had something like:
> 
> int t = (int)uclock();
> while(t < 0x2000)
> {
>   printf("%i", t);
>   t = (int)uclock();
> }

How did you expect this to work?  `uclock_t' is typedef for 
"long long" (see the header time.h), which is a 64-bit quantity.
When you cast it to an int, which is a 32-bit quantity, you lose
all of the upper 32 bits, and look at the least-significant bits
only!

What you need to do is to use the %Ld format specifier to print the 
entire uclock_t result, without casting it.  *Then* look at the
numbers and see if they make sense.

- Raw text -


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