Skip to content

Variant to string convertion should use CurrToStr for varCurrency

Summary

Now,

VariantVar := ReallyLargeCurrencyVar;
StrVar := VariantVar; // here compiler use FloatToStr to convert currency to string

But due to the implementation of FloatToStr, it outputs unexpected result for large currency (822337203685477.5807 -> "822337203685478")

System Information

  • Operating system: Linux (ubuntu)
  • Processor architecture: x86-64
  • Compiler version: trunk (299c90b9)
  • Device: Computer

Steps to reproduce

var
  C: Currency;
  V: Variant;
  S: string;
begin
  C := 822337203685477.5807;
  V := C;
  S := V;
  WriteLn(S); // Expected 822337203685477.5807, actual 822337203685478
end;
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information