[Top][All Lists]

[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 03:30:20 -0500
User-agent: Mozilla Thunderbird 1.0.7 (X11/20051013)

I'm resending this because I received my follow up but not the original 

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

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...


reply via email to

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