29/06/2022 17:28 Delphi Basics : Currency command
DelphiBasics Your advert here
Click to inquire
Currency A decimal type with 4 decimal points used for financial values System unit
Type
type Currency;
Description Example code : Rounding up and down currency amounts
The Currency type is designed for use in financial applications. var
It supports 4 decimal places with at least 53 bits precision*.
account1, account2, account3 : Currency;
begin
Decimal places beyond the supported 4 are rounded up or account1 := 123.456749; // Too many decimals - will be rounded down
down, as appropriate. See the sample code for an example.
account2 := 123.456750; // Too many decimals - will be rounded up
account3 := account1 + account2;
Notes
ShowMessage('Account1 = '+CurrToStr(account1));
* Depends on the processor floating point precision. ShowMessage('Account2 = '+CurrToStr(account2));
ShowMessage('Account3 = '+CurrToStr(account3));
Very large Currency values will lose precision with some of the end;
StrUtils functions.
Show full unit code
Related commands Account1 = 123.4567
Account2 = 123.4568
CurrToStr Convert a currency value to a string
Account3 = 246.9135
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
Author links
Download this web site as a Windows program.
A Big Hit with Young
Adults
Queen's Blade
'
'
'
Delphi Programming © Neil Moffatt 2002 - 2020. All rights reserved. | Home Page
www.delphibasics.co.uk/RTL.asp?Name=Currency 1/1