4D v14.3

Numeric Operators

Home

 
4D v14.3
Numeric Operators

Numeric Operators  


 

 

An expression that uses a numeric operator returns a number. The following table shows the numeric operators:

OperationSyntaxReturnsExpressionValue
AdditionNumber + NumberNumber2 + 35
SubtractionNumber – NumberNumber3 – 21
MultiplicationNumber * NumberNumber5 * 210
DivisionNumber /NumberNumber5 / 22.5
Longint divisionNumber \ NumberNumber5 \ 22
ModuloNumber % NumberNumber5 % 21
ExponentiationNumber ^ NumberNumber2 ^ 38

The modulo operator % divides the first number by the second number and returns a whole number remainder. Here are some examples:

  • 10 % 2 returns 0 because 10 is evenly divided by 2.
  • 10 % 3 returns 1 because the remainder is 1.
  • 10.5 % 2 returns 0 because the remainder is not a whole number.

WARNING:

  • The modulo operator % returns significant values with numbers that are in the Long Integer range (from minus 2^31 to 2^31 minus one). To calculate the modulo with numbers outside of this range, use the Mod command.
  • The longint division operator \ returns significant values with integer numbers only.

 
PROPERTIES 

Product: 4D
Theme: Operators

 
SEE ALSO 

Bitwise Operators
Comparison Operators
Date Operators
Logical Operators
Operators
Picture Operators
String Operators
Time Operators

 
ARTICLE USAGE

4D Language Reference ( 4D v12.4)
4D Language Reference ( 4D v11 SQL Release 6)
4D Language Reference ( 4D v14 R3)
4D Language Reference ( 4D v14 R2)
4D Language Reference ( 4D v13.5)
4D Language Reference ( 4D v14.3)
4D Language Reference ( 4D v14 R4)