PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • The currency type
  • Notes
  • Default value
  • Binary coding of reals
  • Thousand separator
  • Calculations on currencies
  • External language
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
The currency type
A currency is a real coded on 10 bytes.
A currency can contain up to 23 significant digits (17 for the integer part and 6 for the decimal part) and it can take a value included between -604 462 909 807 314 587, 353 087 and +604 462 909 807 314 587, 353 087.
The currency type is recommended to avoid the rounding errors caused by the binary coding of reals.
Notes:
  • For a better precision, we recommend that you use the numerics (38 significant digits).
  • For the other calculations, we recommend that you use the reals.
  • PHP The numbers (real, integer, currency, numeric) cannot exceed 14 significant digits in PHP. If they exceed this limit, they are rounded to 14 digits.
Notes

Default value

A "Currency" variable that is declared but not initialized is equal to 0.
To force the assignment of a currency, use 0m in front of the value. For example:
num1 is currency
num1 = 0m12345678901234567891234567
Trace(num1)

Binary coding of reals

All the reals have the same number of significant digits (15).
If the result of a calculation performed on reals involves 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.
The numerics provide an even greater precision (32 digits for the integer part and 6 digits for the decimal part).
Versions 23 and later

Thousand separator

The 'Space' character or the '_' character can be used as thousand separator in the numbers. For example:
num1 is currency
num1 = 123 456.478

num2 is currency
num2 = 568_014.478
New in version 23

Thousand separator

The 'Space' character or the '_' character can be used as thousand separator in the numbers. For example:
num1 is currency
num1 = 123 456.478

num2 is currency
num2 = 568_014.478

Thousand separator

The 'Space' character or the '_' character can be used as thousand separator in the numbers. For example:
num1 is currency
num1 = 123 456.478

num2 is currency
num2 = 568_014.478

Calculations on currencies

All the calculations that use at least one currency will be performed in currency format. For a better precision of the result, all the operands will be automatically converted into currency.
Caution: Change of behavior between version 12 and version 14:
In version 12, when a real was multiplied by a currency, the calculation was performed on reals.
From version 14, when a real is multiplied by a currency, the calculation is performed on currencies.
Note: For better precision, we recommend that you use the Numeric type to perform calculations.

External language

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