Home | Sign in | English  Help WLanguage WLanguage syntax Type of data Advanced types Numeric Presentation Example Assigning a numeric value Thousand separator Operations available for the numeric type Operation that involves a numeric Limit Currency/Numeric comparison See also  Character strings Converting C types Currencies Date DateTime Duration JSON Numeric Operations available for the dates, times and durations, ... Reals Rectangle The "Buffer" type The Variant type The different types of data The different types of integers Time UUID
 Assigning a numeric valueThousand separatorOperations available for the numeric typeOperation that involves a numericLimitCurrency/Numeric comparison WINDEV      WEBDEV    WINDEV Mobile      Others 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 arrayas element of composite variableas element of structureas element of class.A variant can contain a numeric.Example Counter is numericCounter is numeric (*)Counter is numeric (5,7) num1 is numeric (2,15)num2 is numeric (2,15)num1 = 0n10.000000000000033num2 = 0n10.000000000000055Info(num1+num2) Syntax Declaring a numeric type (default number of digits: 32 digits for the integer part and 6 digits for the decimal part) is numeric, are numerics : 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) is numeric (*), are numeric (*) : 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 is numeric (), are numeric () : Name of variable to declare. : 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 is numeric (, ), are numeric (, ) : Name of variable to declare. : Number of digits in the integer part. A numeric can contain up to 38 significant digits. : Number of digits in the decimal part. A numeric can contain up to 38 significant digits.Remarks Assigning a numeric valueWhen 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 numericnum1 = 1234567890123456789123456789Trace(num1) // num1 does not contain the correct value num2 is numericnum2 = 1234567890123456789.0Trace(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 numericnum1 = 0n1234567890123456789123456789Trace(num1) // num1 contains the correct value num2 is numericnum2 = 0n1234567890123456789.0Trace(num2) // num2 contains the correct value Versions 23 and laterThousand separatorThe 'Space' character or the '_' character can be used as thousand separator in the numbers. For example: num1 is numericnum1 = 123 456.478num2 is numericnum2 = 0n 47 568 014.478num3 is numericnum3 = 7_014.478 New in version 23Thousand separatorThe 'Space' character or the '_' character can be used as thousand separator in the numbers. For example: num1 is numericnum1 = 123 456.478num2 is numericnum2 = 0n 47 568 014.478num3 is numericnum3 = 7_014.478 Thousand separatorThe 'Space' character or the '_' character can be used as thousand separator in the numbers. For example: num1 is numericnum1 = 123 456.478num2 is numericnum2 = 0n 47 568 014.478num3 is numericnum3 = 7_014.478 Operations available for the numeric typeThe following operations can be performed on the numeric type:Comparison operations: ability to use the =, <>, <, <=, >, >= operatorsArithmetic operations: Addition (+), negation (-), subtraction (-), multiplication (-), division (/), modulo.Combined operations: ++, --,+=, -=Operation that involves a numericDuring 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.LimitA 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. 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 comparisonThe 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). See also Minimum required version Version 9 This page is also available for…