 Operators: /

Division operator.

Syntax

integer‑operand/integer‑operand

float‑operand/float‑operand

float‑operand/integer‑operandorinteger‑operand/float‑operand

Integer division

In its first version, the / operator divides the left integer operand by the right integer operand. If used in combination with 8-, 16- or 32-bit signed integer operands, the data type resulting from the operation is consequently int32. When mixing signed and unsigned integer operands, the operation results in the unsigned uint32 value. In the case, one of the operands is 64-bit large, the resulting data type is int64 or uint64 according to whether the 64-bit operand is signed or unsigned. Please note, trying to perform the division with the right operand == 0 (zero) will raise a 'division by zero' runtime CPU exception. For example:

var int32  a = 2500;
var int32  b = -7;
var uint32 c = 1098;
var uint32 d = 57;
var uint64 e =  897546641189;
var int64  f = -149613691251;

var int32  result = a / b; // result = -357
var uint32 result = c / d; // result = 19
var uint32 result = b / d; // result = 75350303 (overflow)
var int64  result = f / d; // result = -2624801600
var uint64 result = e / d; // result = 15746432301

Floating point division

In its second version, the / operator divides the left floating-point operand by the right floating-point operand. If used in combination with a signed or unsigned integer operand, the integer operand is automatically converted to float before performing the division. The resulting data type of the operation is always a float. Please note, trying to perform the division with the right operand == 0.0 (zero) will raise a 'division by zero' runtime CPU exception. For example:

var float  a = 1369.1251;
var float  b = -14.96;
var int32  c = 2;

var float  result = a / b; // result = -91.51905822
var float  result = a / c; // result = 684.562561