Why use float and double instead of real?
Don
nospam at nospam.com
Wed Jul 1 06:26:42 PDT 2009
Lars T. Kyllingstad wrote:
> Is there ever any reason to use float or double in calculations? I mean,
> when does one *not* want maximum precision? Will code using float or
> double run faster than code using real?
>
> I understand they are needed for I/O and compatibility purposes, so I am
> by no means suggesting they be removed from the language. I am merely
> asking out of curiosity.
>
> -Lars
Size. Since modern CPUs are memory-bandwidth limited, it's always going
to be MUCH faster to use float[] instead of real[] once the array size
gets too big to fit in the cache. Maybe around 2000 elements or so.
Rule of thumb: use real for temporary values, use float or double for
arrays.
More information about the Digitalmars-d-learn
mailing list