[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-libc-dev] Math accuracy
From: |
David Carr |
Subject: |
[avr-libc-dev] Math accuracy |
Date: |
Mon, 24 Apr 2006 02:30:27 -0500 (CDT) |
User-agent: |
SquirrelMail/1.4.4 |
Just for fun I ran the "savage" benchmark on my Mega16 at 6MHz. I
attempted to use double precision everywhere. (I say attempted because
I'm no expert at this.)
double d = 1;
uint16_t i;
for (i=1; i<2500; i++)
{
d = tan(atan(exp(log(sqrt(d*d))))) + 1;
}
Here are the results, (correct answer is 2500)
P4 (equivalent code):
float: 2477.24414062500000000000
float error: 22.75585937500000000000
double: 2500.00000000117734089145
double error: -0.00000000117734089145
long double: 2499.99999999999997846167
long error: 0.00000000000002153833
AVR
float: 2476.24536132812500000000
error: 23.75463867187500000000
double: 2476.24536132812500000000
error: 23.75463867187500000000
Execution required 8.28sec at 6MHz.
A further test reveals (to me) that sizeof(float) == sizeof(double) == 4.
Is there a way to have sizeof(double) == 8?
I'm not using anything like this in a real application but I thought it
was an interesting result...
-DC
- [avr-libc-dev] Math accuracy,
David Carr <=