ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage syntax / WLanguage types
  • Default value
  • Binary encoding of real numbers
  • Thousand separator
  • Precision issues with reals
  • PHP-specific features
  • Differences with WINDEV/WEBDEV 5.5
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Real (Variable type)
In french: Real
The Real type allows you to perform calculations on real values using up to 15 significant digits. This type might suffer from loss of precision.
For accurate calculations, use "Currency".
The Real type supports null values. For more details, see Allowing nullable types.
Example
Num1 is real
Syntax
<Variable name> is real
<Variable name 1>, <Variable name 2> are reals
<Variable name>:
Name of the variable to declare. This variable will be an 8-byte real. A real can contain up to 15 significant digits. The value of a real corresponds to:
  • Minimum value:1.7*10-308
  • Maximum value: 1.7*10+308
<Variable name> is 4-byte real
<Variable name 1>, <Variable name 2> are 4-byte reals
<Variable name>:
Name of the variable to declare. This variable will be a 4-byte real. A 4-byte real can contain up to 6 significant digits.
The value of a 4-byte real corresponds to:
  • Minimum value: 3.4*10-38
  • Maximum value: 3.4*10+38
AndroidAndroid Widget Java This type is not supported. It is replaced with a real.
Remarks

Default value

A "Real" variable that is declared but not initialized is equal to 0.

Binary encoding of real numbers

All the reals contain 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. For a better precision, use the Currency or Numeric type.

Thousand separator

You can use spaces and underscore characters to separate thousands in numbers. For example:
num1 is real
num1 = 123 456.478

num2 is real
num2 = 7_014.478

Precision issues with reals

Operations with the "Real" type are not precise because of the computer representation of real numbers.
Two reals that are equal mathematically speaking are not necessarily equal computer-wise and the ">", "<" or "=" operators can return results that are "false" mathematically speaking.
To solve some of these problems:
  • the "=" operator achieves a precision of 10e-6 on reals. Therefore, for two reals that are relatively close, the "=" and ">" operators (or "=" and "<") can return True for the same values.
  • the conversion of real values to strings uses a complex algorithm. This is why, in most cases, the data displayed in the trace is correct.
To avoid these problems, use the Currency or Numeric type, which uses an exact memory representation.
PHP

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.
WINDEVWEBDEV - Server codeReports and QueriesWindowsUser code (UMC)

Differences with WINDEV/WEBDEV 5.5

Real types have changed between WINDEV/WEBDEV 5.5 and WINDEV/WEBDEV 2025:
Real types
in version 5.5
Real types
in version 2025
Real4-byte real
Turbo realNot available anymore
Double realReal

In WINDEV and WEBDEV 5.5, 4-byte reals were used by default. In WINDEV and WEBDEV 2025, 8-byte reals are used by default.
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/25/2024

Send a report | Local help