[fpc-pascal] Variants and Extended

Torsten Bonde Christiansen tc at epidata.dk
Thu Sep 17 09:04:52 CEST 2009

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?

I would be glad if someone could give me some feedback on this.

Kind regards,
Torsten Bonde Christiansen.

More information about the fpc-pascal mailing list