ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage syntax / 
  • Assigning a numeric variable
  • Thousand separator
  • Operations that can be performed with a numeric type
  • Operation involving a numeric type
  • Limitations
  • Currency/Numeric comparison
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Numeric (Variable type)
In french: Numerique
The numeric type is used to contain integer or decimal numbers by specifying if necessary:
  • the number of digits in the integer part.
  • the number of digits in the integer part and in the decimal part.
This variable type is recommended for calculations on real values requiring high precision. A numeric supports 38 significant digits (up to 32 digits for the integer part and 6 digits for the decimal part). Precision is set to 6 decimal places.
The Numeric type supports null values. For more details, see Allowing nullable types.
Example
Counter is numeric
Counter1 is numeric (*)
Counter2 is numeric (5,7)
num1 is numeric (2,15)
num2 is numeric (2,15)
num1 = 0n10.000000000000033
num2 = 0n10.000000000000055
Info(num1+num2)
Syntax

Declaring a numeric type (default number of digits: 32 digits for the integer part and 6 digits for the decimal part) Hide the details

<Variable name> is numeric

<Variable name 1>, <Variable name 2> are numeric
<Variable name>:
Name of the variable to declare. This variable will be a numeric variable with 32 digits for the integer part and 6 digits for the decimal part.

Declaring a numeric type (automatic number of digits) Hide the details

<Variable name> is numeric (*)

<Variable name 1>, <Variable name 2> are numeric (*)
<Variable name>:
Name of the variable to declare. (*) means that the variable format automatically adapts to the value contained.

Declaring a numeric type while specifying the integer part Hide the details

<Variable name> is numeric (<Integer part>)

<Variable name 1>, <Variable name 2> are numeric (<Integer part>)
<Variable name>:
Name of the variable to declare.
<Integer part>:
Number of digits in the integer part. A numeric can contain up to 38 significant digits.

Declaring a numeric type while specifying the integer part and the decimal part Hide the details

<Variable name> is numeric (<Integer part>, <Decimal part>)

<Variable name 1>, <Variable name 2> are numeric (<Integer part>, <Decimal part>)
<Variable name>:
Name of the variable to declare.
<Integer part>:
Number of digits in the integer part. A numeric can contain up to 38 significant digits.
<Decimal part>:
Number of digits in the decimal part. A numeric can contain up to 38 significant digits.
Remarks

Assigning a numeric variable

When assigning a value (value entered directly, given by a function, etc.) to a numeric value, this value is automatically converted into real by the compiler.
For example:
num1 is numeric
num1 = 1234567890123456789123456789

Trace(num1) // num1 does not contain the correct value
num2 is numeric
num2 = 1234567890123456789.0
Trace(num2) // num2 does not contain the correct value
To force the assignment of a numeric type, use 0n before the value. For example:
num1 is numeric
num1 = 0n1234567890123456789123456789
Trace(num1) // num1 contains the correct value
num2 is numeric
num2 = 0n1234567890123456789.0
Trace(num2) // num2 contains the correct value

Thousand separator

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

num2 is numeric
num2 = 0n 47 568 014.478

num3 is numeric
num3 = 7_014.478

Operations that can be performed with a numeric type

The following operations can be performed with numeric variables:
  • Comparison operations: ability to use the =, <>, <, <=, >, >= operators
  • Arithmetic operations: Addition (+), negation (-), subtraction (-), multiplication (-), division (/), modulus.
  • Combined operations: ++, --,+=, -=

Operation involving a numeric type

During an operation that involves a numeric variable, all the calculations are performed in the format of the numeric values handled.
For example, to perform an operation involving a numeric variable and a real, the real is converted to numeric.

Limitations

A numeric type can have 38 significant digits.
The "highest" cases ((0,38) or (1,37) for example) can produce calculations errors caused by overflows.
The "lowest" cases ((38,0) or (37,1) for example) can produce calculation errors caused by loss of decimal values.

Currency/Numeric comparison

The Currency type is faster for the calculations that do not require a precision greater than 24 significant digits (up to 17 digits for the integer part and up to 6 digits for the decimal part).
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/26/2024

Send a report | Local help