Re: doubles or not

From: Roy Fine (rlfine_at_twt.obfuscate.net)
Date: 04/14/04


Date: Tue, 13 Apr 2004 23:31:18 -0400


"bdg" <ased@noo.com> wrote in message
news:emhgrAdIEHA.3988@tk2msftngp13.phx.gbl...
> "Avoid using doubles when integers will do..."
>
> How could this be true? Since whenever we have to represent a number to
> certain extent of accuracy of certain digits after decimal point and when
> even a float can not be enough for this, we may need doubles. Am I
missing
> something?
>

the point that you are missing is "..when integers will do". Never use a
double to store any of the natural numbers or their negatives or 0. Storing
doubles is expensive (8 bytes versus 4 bytes on some machines), and on most
hardware platforms, doing floating point math is more expensive than doing
integer math.

In places where an integer will not do, then consider using a double or a
float.

regards
roy fine

> Thanks!
>
>
>



Relevant Pages

  • Re: doubles or not
    ... George Hester ... > even a float can not be enough for this, we may need doubles. ... Am I missing ...
    (microsoft.public.vc.language)
  • doubles or not
    ... "Avoid using doubles when integers will do..." ... even a float can not be enough for this, we may need doubles. ... Am I missing ...
    (microsoft.public.vc.language)
  • Re: why float
    ... A double *is* a float with more precision. ... It is possibly to do with spurious precision in the doubles - in numerical ... I think it depends on teh algorithm as well. ... single-precision in order to stop rounding errors from amplifying ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: increased machine precision for FreeBSD apps?
    ... > arithmetic (e.g. scientific computation apps for one, ... > rounding errors by increasing the data type size? ... Most programmers expect a float to be an IEEE 754 single-precision ... On most modern FPUs, however, floats, doubles, and sometimes even ...
    (freebsd-arch)
  • Re: libc/printf bug
    ... I don't see that the cast should have any effect at all ... How would you print a float in hex? ... So seems printf gets confused because you present it with a float when i t wants an integer. ... This behavior I have seen in other cases where wrong or missing arguments were presented too. ...
    (comp.os.linux.development.apps)