[fpc-pascal] Variants and Extended

Michael Van Canneyt michael at freepascal.org
Thu Sep 17 09:13:10 CEST 2009



On Thu, 17 Sep 2009, Torsten Bonde Christiansen wrote:

> Dear list.
>
> Over the last couple of days i've been trying out different things with 
> variants, but I always seem to end up in the same situation: When working 
> with conversion between Extended and Variant, a small part of the precision 
> in the Extended is lost.
>
> This would normally not pose an issue, except for the fact that comparing two 
> Extended variables after one was converted to a variant and back, the two 
> numbers are NOT equal. (I've posted a small example at the bottom of the 
> mail).
>
> I did some digging down the FPC code and found that in the TVarData type has 
> not extended type. Although the assignment operator for variants does include 
> a specific extended version, data is copied into a double type.
>
> Not knowing much about the inner working of variants I don't know the reason 
> for this, is it a bug or does the extended type not work inside the TVarData?

The extended type does not work inside TVarData. Variants were implemented
by Microsoft, and they did not include support for extended.

Michael.



More information about the fpc-pascal mailing list