Jon S. Berndt wrote:

> I am thinking that some of our problems in JSBSim may be due to
> numerical precision. To rule out this I am considering moving all
> floats to doubles. The results of this are something I am not fully
> able to address, so I am asking for opinions on this:
> 
> 1) Bad idea? Good idea? Why?

Probably not a great idea, but certainly no catastrophe either.
Numerical precision problems are best solved by understanding and
mitigating them, not clubbing them over the head with extra
precision. :)

If the number requires more than 23 bits of mantissa to represent
(latitude and longitude are the only ones I can think of for an FDM
that require this) then by all means use a double.  But promoting
things like velocity or engine speed to doubles isn't going to buy you
anything.

The really nasty precision problems (accumulated error) should only
creep up in situations where the same number gets acted on over and
over; literally millions of times.  I don't think this is the case
with JSBsim, or an FDM in general, which should touch any given number
only once (or some small number of times) per iteration or so.

> 2) Would this increase execution time?

Probably only very slightly.  Unless you play fun games with the
assembler, all the calculations are done at full precisions per the C
language specification.  The only problem that should crop up is space
-- doubles are twice as big as floats, and will therefore take up
twice as much of the cache.  My guess is this effect would be
measurable, but insignificant.

Really, the preformance relation goes the other way around: IF you can
force all your calculations to fit in floats, AND are willing to play
dirty tricks with the FPU, you can squeeze out more performance from
an x86 processor.  Division can get a 2x speedup or so when done in
single precision, as can most of the trig operations, I think.  Other
math ops (add/sub/mul) are latency limited instead of calculation
limited, and won't change much.

Andy


-- 
Andrew J. Ross                NextBus Information Systems
Senior Software Engineer      Emeryville, CA
[EMAIL PROTECTED]              http://www.nextbus.com
"Men go crazy in conflagrations.  They only get better one by one."
  - Sting (misquoted)


_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to