From fcef25f6ef36287a4984ffdaab39df84f5aceeba Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 21 Jun 2026 15:49:24 +0900 Subject: refactor(php-shim): split lib.rs --- crates/shirabe-php-shim/src/math.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 crates/shirabe-php-shim/src/math.rs (limited to 'crates/shirabe-php-shim/src/math.rs') diff --git a/crates/shirabe-php-shim/src/math.rs b/crates/shirabe-php-shim/src/math.rs new file mode 100644 index 0000000..fffe2d6 --- /dev/null +++ b/crates/shirabe-php-shim/src/math.rs @@ -0,0 +1,33 @@ +pub fn max_i64(_a: i64, _b: i64) -> i64 { + _a.max(_b) +} + +pub fn max(_a: i64, _b: i64) -> i64 { + _a.max(_b) +} + +pub fn min(_a: i64, _b: i64) -> i64 { + _a.min(_b) +} + +pub fn abs(_value: i64) -> i64 { + _value.abs() +} + +pub fn floor(_value: f64) -> f64 { + _value.floor() +} + +pub fn ceil(v: f64) -> f64 { + v.ceil() +} + +pub fn round(_value: f64, _precision: i64) -> f64 { + todo!() +} + +pub fn intdiv(a: i64, b: i64) -> i64 { + // PHP intdiv() throws DivisionByZeroError on a zero divisor and ArithmeticError + // for PHP_INT_MIN / -1; Rust's `/` likewise panics in both cases. + a / b +} -- cgit v1.3.1