Table Of Contents

Performing Division with Expression Functions and Operators

Last Modified: June 10, 2021

Use the division operator or quotient function to divide expression functions and operators.

The division operator (/) method divides all numbers as doubles and results in a double quotient, regardless of the data type of the dividend or divisor.

If the dividend, divisor, and result are all of type I32, the division operator performs an integer division and returns a result of data type I32.

The quotient function method rounds the result of the division towards minus infinity.

Depending on your goal, use a division method with your expression function or operator.
Goal Method
Perform an integer division and want the result as a double Division Operator (/)
Perform an integer division and want the result as an integer rounded towards minus infinity Quotient Function
Divide U64 integers
The result of the function (operator) is either the data type of the dividend or the divisor. This is determined by the largest data type, according to this order: Double > U64 > I64 > U32 > I32.

If the result is passed to another data type, VeriStand performs an implicit cast. An implicit cast converts one data type to another. For example, if a double is converted to an integer, the resulting number is rounded toward zero. This may lead to unexpected values.

The following table shows the results of different functions in the case of division by zero.
Function/Operator Double Integer (I32, I64, U32, U64)
mod(x,y) Nan The sequence is aborted with error -8
quotient(x,y) -Inf/Nan/Inf
rem(x,y) Nan
/ -Inf/Nan/Inf
% Nan

Recently Viewed Topics