delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/29/19:12:40

From: leathm AT solwarra DOT gbrmpa DOT gov DOT au (Leath Muller)
Message-Id: <199701300007.KAA09793@solwarra.gbrmpa.gov.au>
Subject: Re: doubles vs. floats
To: chambersb AT juno DOT com (Benjamin D Chambers)
Date: Thu, 30 Jan 1997 10:07:24 +1000 (EST)
Cc: djgpp AT delorie DOT com
In-Reply-To: <19970129.150806.4951.1.chambersb@juno.com> from "Benjamin D Chambers" at Jan 29, 97 06:07:30 pm

> >> This may sound a little counterintuitive, but sometimes you can get 
> >better
> >> results by using doubles rather than floats.

> >Why is this? I've heard it many times, but never understood why.

> Because the FPU only works with doubles.  So to use floats, you have to
> go through conversions such as:
> float->double->float
> Which can get rather slow if you use enough.  The only good argument for
> floats is that they don't use as much memory, but a few bytes probably
> won't make much difference IMHO.

I actually did a lot of timing and testing on this, and found using
doubles made no difference to the number of cycles it took to do a
calculation (on the pentium folks... :) I think the FPU converts all
loaded values to 80bit values, whether they are floats (32 bit) or
doubles (64 bit) to do the calculations, and takes no time to do so.
Doubles have the advantage of being more accurate for calculations
than floats do.

Leathal.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019