Re: NSTimer or double to int cast (Bug?)
Re: NSTimer or double to int cast (Bug?)
- Subject: Re: NSTimer or double to int cast (Bug?)
- From: Marco Binder <email@hidden>
- Date: Sat, 11 Jan 2003 17:49:58 +0100
OK, NSTimer somehow returns a different interval-value than the one I
initialized it with on the tested G3s. On my G4, it return exactly the
same as I have set.
My code:
- (id) init {
if (self = [super init]) {
testDouble = 1.0;
timer = [[NSTimer scheduledTimerWithTimeInterval:testDouble
target:self selector:@selector(timerAction:) userInfo:nil repeats:YES]
retain];
}
return self;
}
- (void) timerAction: (id) sender {
double time = [timer timeInterval];
printf("original double=%x%x\n", *(long*)(&testDouble),
*(((long*)(&testDouble)) +1));
printf("NSTimer interval=%x%x\n", *(long*)(&time),
*(((long*)(&time)) +1));
}
On my G4, both hex values are the same:
original double=3ff000000
NSTimer interval=3ff000000
On the iBook however its:
original double=3ff000000
NSTimer interval=3feffffff7ef12d5
Very obviously, NSTimer does something to the timeinterval, not just
putting it into an ivar...
marco
Am Samstag, 11.01.03 um 16:33 Uhr schrieb Chris Ridd:
On 11/1/03 2:35 pm, Marco Binder <email@hidden> wrote:
I am using the same binary, but compiling it again on the iBook (both
have dec devtools and gcc 3.1) doesnt change anything.
OK, just now I4ve done some comparison and calculation stuff:
[timer timeInterval]<1.0 return NO on my G4 and YES on my iBook!
([timer timeInterval]-1.0) * 10000 returns 0.00000 on my G4 and
-0.00150 on my iBook!
So the returned timeInterval is NOT equal to the value passed for
initialization on all machines. I still consider that to be a bug,
altough one with easy workarounds.
Somehow it seems to be correlated with the machines speed, as
Cameron4s
600 MHz iBook works as expected (that is: correct), whereas my 500 MHz
iBook, my girlfriends 400 MHz G3 iMac and another developers 400 MHz
iMac all three show the deviation.
Are all those G3 processors the same? What bit pattern does the double
contain on all machines?
Cheers,
Chris
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
--
|\ /| E-Mail: email@hidden WWW: www.marco-binder.de
| \/ | Telefon: 07531 / 94 19 94 Fax: 07531 / 94 19 92
| |ARCO Snail-Mail: Banater Str. 3 - 78467 Konstanz
BINDER _____________________________________________________
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.