[fpc-pascal] Currency and ABS(-674.59)

Ludo Brands ludo.brands at free.fr
Tue Mar 6 14:13:17 CET 2012


> >> Note that this requires compiler patching, because abs() 
> is internal 
> >> (it can be used in constant expressions). I would 
> personally argue to 
> >> do away entirely with the "treat currency as a floating 
> point type on 
> >> i386 so it can use the 80x87", and instead map it 
> implementation-wise 
> >> to int64 like on all other platforms. You may lose a bit of 
> >> performance, but you'll gain consistency. And you won't need hacks 
> >> like this (which, as mentioned before, only solves one particular 
> >> use-case, and so I'm not very much in favour of doing this).
> >
> > As far as I know, Currency is always a scaled int64, and didn't 
> > interpret the request as a request to change that. I missed 
> probably 
> > part of the argumentation but on the face of it, having a 
> > ABS(Currency) seems like a reasonable request.
> 
> No, Currency is based on Extended on i386 and x86_64 (except win64!).
> 
> Regards,
> Sven
> 

There is also a lot of code in the rtl and fcl-db that supposes currency =
double. Fe. 

Function CurrToStr(Value: Currency; Const FormatSettings: TFormatSettings):
string;
begin
  Result:=FloatToStrF(Value,ffGeneral,-1,0,FormatSettings);
end;  
      
Or

TCurrencyField = class(TFloatField)

Ludo




More information about the fpc-pascal mailing list