[fpc-devel] Extended type

Hans-Peter Diettrich DrDiettrich1 at aol.com
Wed Apr 20 15:04:51 CEST 2011


Florian Klämpfl schrieb:
> Am 20.04.2011 00:05, schrieb Hans-Peter Diettrich:
>> Florian Klaempfl schrieb:
>>
>>> Using extended typically hides only bad numerical algorithms. There
>>> might be some corner cases where extended is usefull but I general I
>>> think it's a matter of bad algorithms.
>> Some algorithms convert faster with increased accuracy.
> 
> I guess you meant converge?

Right. I had a phone call just while answering :-(

> This might be true, but processing of
> extended types is also slower: the memory footprint increases and even
> worse, extended arrays are typically aligned to 4 or even 16 byte
> borders so they take 12 or 16 byte in memory.

Please don't mix up the internal processing and the external storage of 
the values. Type coercion (expansion) is frequently used in the 
evaluation of expressions, be inside a GPU or FPU.

> Further, more complex
> floating point operations than +,-,* are also typically slower when the
> fpu is set to extended precision. So even if an algorithm converges in
> less steps with extended, the overall computation time might not decrease.

In contrast computations with extended precision can eliminate the need 
for additional checks of intermediate results (overflow, underflow...), 
which have to be inserted explicitly in other cases.

Of course there exists no general rule, it depends on the concrete 
purpose of a calculation, which algorithm, precision and type (BCD, 
fixed point...) yields the "best" results. But there also exists no 
reason why a coder should be prevented from using existing instructions 
and data types.

DoDi




More information about the fpc-devel mailing list