Re: why float




Nick Hounsome wrote:
"Martijn Mulder" <i@m> wrote in message
news:44536053$0$12852$dbd4d001@xxxxxxxxxxxxxxxxxx
Waaaay back in my university days, in my Numerical Analysis course, I
remember one example in which using doubles everywhere (the obvious
solution) actually increased error and gave a less precise answer than
judicious application of floats in the right places.
<snip>

That is unlikely. A double *is* a float with more precision. So it will
always be as precise or more precise than a flaot is. Answers given in the
line of "32 bit is favored" are platform-dependenpt and not realy
convincing. Why is there a fundamental type 'float' and a fundamental type
'double' that both do the same thing? When to use the one, when to use the
other?

What he is saying rings a bell with me too.

Unfortunately I failed my numerical analysis block so I can't add an
authoritative explanation either :(

It is possibly to do with spurious precision in the doubles - in numerical
analysis the inputs are usualy measurements approximating the true values
and do not have the number of significant digits in a double so when you
start using these extra digits you can introduce more error than if you
stuck with float ... or not. I think it depends on teh algorithm as well.

Yes, that's more or less what I remember, too.

It's not realy an argument for float though because you can acheive the same
or better results by using double and reworking the algorithm and/or
rounding here and there.

Agreed. It was just that certain algorithms required judicious use of
single-precision in order to stop rounding errors from amplifying
themselves. I remember it only because it was counter-intuitive.

.



Relevant Pages

  • Re: Standard Deviation
    ... Depending on the input data, this might be int64, extended, or perhaps even a large integer or large float class. ... If you look at the formula, you will see that the value for the SS is computed as a relatively small difference between two numbers that can become very large if the number of values thrown at the algorithm is very large. ... After the loop the average needs no further adjustment, while Std contains the sum of squares and needs to be adjusted if you want the standard deviation. ...
    (borland.public.delphi.non-technical)
  • Re: OT : Approximate / fast math libraries ?
    ... some practical work with the algorithm will tell you the real results. ... It costs no more to calculate doubles than singles except ... depends on the hardware implementations inside the processor and the ... cycle I put into it, along with some additional benefit from hardware ...
    (Fedora)
  • Re: How do I rotate a bitmap fast with high quality?
    ... and change float to int using fixed point algorithm. ... I want to know a new algorithm, with high quality and faster speed. ... using a BitBlt to copy *a single pixel* from one image to ...
    (comp.graphics.algorithms)
  • Re: How to calculate a square root of an integer fast?
    ... > I am now using an algorithm here ... > But I find it is slower than float version of sqrtin the ... SSE2 includes a SIMD floating point square root instruction - ...
    (sci.math.num-analysis)
  • Re: How do I rotate a bitmap fast with high quality?
    ... and change float to int using fixed point algorithm. ... I want to know a new algorithm, with high quality and faster speed. ... >though,I could change double type to float type, ...
    (comp.graphics.algorithms)