[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] floating point calculations - How many cycles

From: Bjarne Laursen
Subject: Re: [avr-gcc-list] floating point calculations - How many cycles
Date: Mon, 27 Jun 2005 09:32:32 +0200
User-agent: Mozilla Thunderbird 0.7.3 (Windows/20040803)

intiha Ho gai wrote:

currTime = (uint32_t)(skew_*(double)currTime + offset_);//compensation
over here!!

here the currTime and offset are 32 bit integers, while the skew is a
floating point with value very close to zero (0.999987 therof).
Keep in mind that 'double' has less precision that uint32_t. If you need the full range for currTime you will run in to problems.
Consitter doing something like this

uint32 currTime;
int32 offset;
int16 gain;
currTime =  (((int64_t)currTime*gain)>>16) + offset;

The shift determines the resolution for gain,.
(Yes, It will take a long time)

-Bjarne Laursen, RoseTechnology A/S

reply via email to

[Prev in Thread] Current Thread [Next in Thread]