Recent

Author Topic: Currency  (Read 2909 times)

lainz

  • Guest
Currency
« on: March 24, 2013, 07:19:36 pm »
Hi, what I'm doing wrong:

Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
var
  a,b,c: currency;
begin
  a := 1.234567890;
  b := 1.234567890;
  c := (a * b) * 2000;
  ShowMessage(CurrToStr(c));
end;     

This show a result of '3048,4743'

In Windows Calculator: '3048,31575..' (10 digits)
In MS Excel: '3048,31575' (general, no number format), '3048,32' (currency format) and 10 digits if I choose 'accounting'.

I've a difference around of 0,16.

What I'm doing wrong, I need the best precision to be calculated and displayed. There's a tutorial or something?

Stefano

  • New Member
  • *
  • Posts: 39
Re: Currency
« Reply #1 on: March 24, 2013, 07:34:48 pm »
Hello,

10 decimals are too many for Currency. Currency should have maximum 4 decimal digits:
http://wiki.freepascal.org/Variables_and_Data_Types

Also the currency fields have maximum 4 decimal points:
http://lazarus-ccr.sourceforge.net/docs/fcl/db/tfieldtype.html

Best regards,

Stefano

Stefano Cortelli
Studio Rag. Cortelli
(Preferred languages: Italiano / Deutsch / Français)

lainz

  • Guest
Re: Currency
« Reply #2 on: March 24, 2013, 07:40:23 pm »
Thanks!! With other data types, like single the precision is suitable for me needs.

 

TinyPortal © 2005-2018