Rust

arith

Module

PHP's arithmetic operators on numbers (Zend/zend_operators.c): integers that overflow become floats, / gives an integer only when the division is exact, and dividing by zero throws.

Contents

use php_std::format::arith::add;
Rust
pub fn add(a: Number, b: Number) -> Number

$a + $b.

use php_std::format::arith::array_sum;
Rust
pub fn array_sum(numbers: impl IntoIterator<Item = Number>) -> Number

array_sum($numbers): + from 0.

use php_std::format::arith::div;
Rust
pub fn div(a: Number, b: Number) -> Option<Number>

$a / $b: None where PHP throws DivisionByZeroError ("Division by zero"), for an integer or float zero divisor.

use php_std::format::arith::mul;
Rust
pub fn mul(a: Number, b: Number) -> Number

$a * $b.

use php_std::format::arith::sub;
Rust
pub fn sub(a: Number, b: Number) -> Number

$a - $b.