Description |
The Currency type is designed for use in financial applications. It supports 4 decimal places with at least 53 bits precision*.
Decimal places beyond the supported 4 are rounded up or down, as appropriate. See the sample code for an example.
|
|
Notes |
* Depends on the processor floating point precision.
Very large Currency values will lose precision with some of the StrUtils functions.
|
|
Related commands |
CurrToStr |
|
Convert a currency value to a string |
CurrToStrF |
|
Convert a currency value to a string with formatting |
Double |
|
A floating point type supporting about 15 digits of precision |
Extended |
|
The floating point type with the highest capacity and precision |
PCurrency |
|
Pointer to a Currency value |
Single |
|
The smallest capacity and precision floating point type |
StrToCurr |
|
Convert a number string into a currency value |
|
|
|
Example code : Rounding up and down currency amounts |
var
account1, account2, account3 : Currency;
begin account1 := 123.456749; // Too many decimals - will be rounded down account2 := 123.456750; // Too many decimals - will be rounded up
account3 := account1 + account2;
ShowMessage('Account1 = '+CurrToStr(account1));
ShowMessage('Account2 = '+CurrToStr(account2));
ShowMessage('Account3 = '+CurrToStr(account3));
end;
|
Show full unit code |
Account1 = 123.4567
Account2 = 123.4568
Account3 = 246.9135
|
|