ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage syntax / WLanguage types
  • Declaration and initialization
  • Binary encoding of real numbers
  • Thousand separator
  • Calculations on currency values
  • External language
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Currency (Variable type)
In french: Currency
The Monetary type is used to perform calculations on real values requiring guaranteed decimal precision, such as monetary values.
A variable of type Monétaire manages 24 significant digits (17 maximum for the integer part, 6 maximum for the decimal part).. A Currency variable corresponds to a 10-byte decimal number.
The Monétaire type is recommended to avoid rounding errors due to the binary coding of real numbers.. An Monetary variable can take a value between -604 462 909 807 314 587,353 087 and +604 462 909 807 314 587,353 087..

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

Remarks:
  • For greater precision, it is recommended to use numerics (38 significant digits). Please note: calculations performed with Numericals will be slower than those performed with Coins..
  • For calculations that don't require great precision, it's preferable to use reals, which are faster.
Example
Prix is currency
Syntax
<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.
Remarks

Declaration and initialization

A "Currency" variable that is declared but not initialized is equal to 0.
When assigning a Monetary type variable with a value (value directly entered, supplied by a function, etc.), this value is automatically converted to real by thecompiler.
To force the assignment of a currency, use 0m in front of the value. For example:
num1 is currency
num1 = 0m12345678901234567891234567
Trace(num1)

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.
Note: For greater precision, we recommend using Numeric type to perform calculations.

External language

The Monétaire type is not available in the external language.
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/20/2024

Send a report | Local help