Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: 64bit math in the kernel



Matt and Brian,

Thanks for the response. The code that I was using that was screwing up
looked like the following:

UInt64 theNanoSeconds;
UInt32 mySamples;

mySamples = 784;
theNanoSeconds = mySamples * 20833333;
theNanoSeconds = theNanoSeconds/1000;


The original multiply would yield a value only in the lower 32 bits of the
UInt64. However, after your emails, I changed the code to the following:

UInt64 theNanoSeconds;
UInt32 mySamples;

mySamples = 784;
theNanoSeconds = (20833333ULL) * mySamples;
theNanoSeconds = theNanoSeconds/1000;


and all seems to be right with the world again. So it looks like if both
multiplacants are 32bit it will do the result as 32bit before putting it in
the 64bit result.

Thanks,
Rob
-----Original Message-----
From: Matt Watson [mailto:email@hidden]
Sent: Monday, August 19, 2002 12:47 PM
To: Robert Penland
Cc: 'email@hidden';
'email@hidden'
Subject: Re: 64bit math in the kernel



On Monday, August 19, 2002, at 12:17 PM, Robert Penland wrote:

> Is it possible and if it is, what is the proper way to handle 64 bit
> math in
> the kernel? Currently, if I have code that multiplies two UInt64
> values, I
> get a bogus value if the result is bigger than what can be contained
> in 32
> bits.

Kernel 64-bit code is (effectively) no different from user-level 64-bit
code.

Please post an example.

matt.
_______________________________________________
darwin-drivers mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-drivers
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.