System.SysUtils.TCurrencyHelper

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

TCurrencyHelper = record helper for Currency

C++

struct TCurrencyHelper /* Helper for real 'System::Currency' */;

Properties

Type Visibility Source Unit Parent
helper
class
public
System.SysUtils.pas
System.SysUtils.hpp
System.SysUtils System.SysUtils

Description

TCurrencyHelper provides support for performing operations with the Currency data type.

Currency is a fixed-point data type that minimizes rounding errors in monetary calculations. It is stored as a scaled 64-bit integer with the 4 least significant digits implicitly representing decimal places. When mixed with other real types in assignments and expressions, Currency values are automatically divided or multiplied by 10000.

TCurrencyHelper Ceil, Floor, and Trunc methods are applied to the integral representation of the currency value, and might not work as you expect given a currency is not a floating-point value.

Example

var
  aNumber: Currency;
begin
  aNumber := 28.65;

  Writeln('Number: ' + aNumber.ToString);
  Writeln('Size: ' + aNumber.Size.ToString);
  Writeln('Frac: ' + aNumber.Frac.ToString);
  Writeln('Trunc: ' + aNumber.ToString);
end.

Console Output:

Number: $28.65
Size: 8
Frac: $0.65
Trunc: $28.65

For a better understanding, below you can find a little explanation of the methods above:

  • ToString returns a string representation of the value, including the locale symbol for the currency.
  • Size returns the bytes used to represent the data.
  • Fraction returns the number after the decimal mark.
  • Trunc returns the integer part of the number representation, which still includes its four decimals.

See Also