PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Assigning a numeric value
  • Thousand separator
  • Operations available for the numeric type
  • Operation that involves a numeric
  • Limit
  • Currency/Numeric comparison
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
Numeric (Type of variable)
In French: Numérique (Type de variable)
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.
A numeric can be used:
  • to declare a simple variable.
  • as element of array
  • as element of composite variable
  • as element of structure
  • as element of class.
A variant can contain a numeric.
Versions 17 and later
iPhone/iPad This type of variable is now available for the iPhone/iPad applications.
New in version 17
iPhone/iPad This type of variable is now available for the iPhone/iPad applications.
iPhone/iPad This type of variable is now available for the iPhone/iPad applications.
Versions 18 and later
Universal Windows 10 App This type of variable is now available in Windows Store apps mode.
New in version 18
Universal Windows 10 App This type of variable is now available in Windows Store apps mode.
Universal Windows 10 App This type of variable is now available in Windows Store apps mode.
Versions 21 and later
Universal Windows 10 App This type of variable is now available in Universal Windows 10 App mode.
Apple Watch This type of variable is now available in Apple Watch mode.
New in version 21
Universal Windows 10 App This type of variable is now available in Universal Windows 10 App mode.
Apple Watch This type of variable is now available in Apple Watch mode.
Universal Windows 10 App This type of variable is now available in Universal Windows 10 App mode.
Apple Watch This type of variable is now available in Apple Watch mode.
Versions 23 and later
Java This type of variable is now available for the Java applications.
Android Widget This type of variable is now available in Android Widget mode.
Android This type of variable is now available for the Android applications.
New in version 23
Java This type of variable is now available for the Java applications.
Android Widget This type of variable is now available in Android Widget mode.
Android This type of variable is now available for the Android applications.
Java This type of variable is now available for the Java applications.
Android Widget This type of variable is now available in Android Widget mode.
Android This type of variable is now available for the Android applications.
Example
Counter is numeric

Counter is numeric (*)

Counter 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

<Name of Variable 1>, <Name of Variable 2> are numerics
<Variable Name>:
Name of 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 (*)

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

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

<Variable Name> is numeric (<Integer Part>)

<Name of Variable 1>, <Name of Variable 2> are numeric (<Integer Part>)
<Variable Name>:
Name of 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>)

<Name of Variable 1>, <Name of Variable 2> are numeric (<Integer Part>, <Decimal Part>)
<Variable Name>:
Name of 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 value

When assigning a value (value entered directly, given by a function, ...) to a numeric, 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, use 0n in front of 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
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 numeric
num1 = 123 456.478

num2 is numeric
num2 = 0n 47 568 014.478

num3 is numeric
num3 = 7_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 numeric
num1 = 123 456.478

num2 is numeric
num2 = 0n 47 568 014.478

num3 is numeric
num3 = 7_014.478

Thousand separator

The 'Space' character or the '_' character can be used as thousand separator in the 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 available for the numeric type

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

Operation that involves a numeric

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

Limit

A numeric can contain up to 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.
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.

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 required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment