Mail Archives: djgpp/1997/02/06/10:38:54
On 5-02-97 20:12, George Foot wrote:
(on float versus double)
> For the record, I threw together a simple test program, which used
> uclock() to time long loops, compiled it with no optimisations, and
> gave the following results:
>
> 1) 5044716 4715005
> 2) 4813001 5153259
>
> These are timings for the loop, taken as the difference between
> uclock() values before and after the loop, the subtraction being done
> at the end of the test (not that that matters much). I believe it is a
> fair test. In (1) The first number represents the time taken for a
> float calculation, the second representing the same calculation in
> doubles. In (2) I reversed the declarations.
>
> The test code was 100000 times through:
>
> a=0.358678735;
> a=sin(a);
> a=cos(a);
> a=a*a;
>
> which (I think) is typical of what most people seem to want floating
> point numbers to do.
>
using the same values, and adding long double (which is what the hardware fpp
uses) I got these results on a Pentium 100:
double: 295461
long double: 282135
float: 285784
long double: 282127
double: 295325
float: 285787
float: 285724
double: 295386
long double: 282127
float: 285727
long double: 282187
double: 295325
Obviously, the sequence of the loops has some, but very small, influence. In
any case, long double is fastest and double slowest. I am not too sure what
this means, but, as you say, the difference is insignificant.
Frank Abbing
> George Foot
- Raw text -