(/) divide operator

(number / number) -> number, const

The division of two numbers. Any division by zero causes a error that interupt the execution of the script.

x = 3 / 4
show scalar "" with x

(i64 / i64) -> i64, const

Divides two i64 values, returning an i64 truncated toward zero. Convert the operands to f64 before division when a fractional result is needed.

integer = to.i64(7) / to.i64(2)
negative = to.i64(-7) / to.i64(2)

show summary "Division" with
  text(integer) as "i64" // 3
  text(negative) as "Negative i64" // -3

(f64 / f64) -> f64, const

Divides two f64 values, returning an f64 and retaining the fractional part within its precision.

x = to.f64(7) / to.f64(2)
show scalar "Quotient" with text(x) // 3.5

(number /. number) -> number, const autodiff

The operation a /. b where a and b are numbers is defined by a / (if b == 0 then 1 else b). This is the “passthrough” division of two numbers.

x = 3 /. 0
show scalar "" with x

The /. passthrough operator has no i64 or f64 overload.

User Contributed Notes
0 notes + add a note