Help / WLanguage / WLanguage syntax / 
  • Declaration and initialization
  • Binary encoding of real numbers
  • Thousand separator
  • Calculations on currency values
  • PHP-specific features
  • External language
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WindowsLinuxPHPWEBDEV - Browser code
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Stored procedures
Currency (Variable type)
In french: Currency
The Currency type is used for calculations involving reals, where high precision is important (e.g., calculations involving money).
Currency variables support 24 significant digits (up to 17 digits to the left of the decimal point and 6 digits to the right). A Currency variable corresponds to a 10-byte decimal number.
The Currency type is recommended to avoid rounding errors caused by the binary encoding of real numbers. Currency variables can have values ranging from -604,462,909,807,314,587.353087 to +604,462,909,807,314,587.353087.

The Currency type supports null values. For more details, see Allowing nullable types.

  • For greater precision, it is recommended to use numerics (38 significant digits). Caution: calculations with numeric variables are slower than with currency variables.
  • For calculations that don't require great precision, it's preferable to use reals, which are faster.
Price is currency
<Variable name> is currency

<Variable name 1>, <Variable name 2> are currencies
<Variable name>:
Name of the variable to declare. This will be a currency variable.

Declaration and initialization

A "Currency" variable that is declared but not initialized is equal to 0.
When a value (entered directly, given by a function, etc.) is assigned to a currency variable, the compiler automatically converts this value to a real.
To force the assignment of a currency, use 0m in front of the value. For example:
num1 is currency
num1 = 0m12345678901234567891234567

Binary encoding of real numbers

All reals have the same number of significant digits (15).
If the result of a calculation performed on reals includes more than 15 significant digits, this result will be automatically rounded to 15 significant digits. The precision of the result will be less than the precision of a calculation performed with the currency type.
numerics provide even greater precision (32 digits for the integer part and 6 digits for the decimal part).

Thousand separator

You can use spaces and underscore characters to separate thousands in numbers. For example:
num1 is currency
num1 = 123 456.478
num2 is currency
num2 = 568_014.478

Calculations on currency values

All the calculations that use at least one currency will be performed in currency format. For a more precise result, all the operands will be automatically converted to currency.
For example, when a real is multiplied by a currency, the calculation is performed using the currency type.
Remark: For greater precision, it is recommended to use the Numeric type to perform calculations.

PHP-specific features

Numbers (real, integer, currency, numeric) cannot exceed 14 significant digits in PHP. If they exceed this limit, they are rounded to 14 digits.

External language

The Currency type is not available in external languages.
Minimum version required
  • Version 9
This page is also available for…
Click [Add] to post a comment

Last update: 04/09/2024

Send a report | Local help