diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-21 15:49:24 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-21 15:49:37 +0900 |
| commit | fcef25f6ef36287a4984ffdaab39df84f5aceeba (patch) | |
| tree | 97ceb2098fbb5642e858929da9578bb41e277ada /crates/shirabe-php-shim/src/math.rs | |
| parent | f0f5f084c883dc4f5b6e61603e82cd1c2092fd9d (diff) | |
| download | php-shirabe-fcef25f6ef36287a4984ffdaab39df84f5aceeba.tar.gz php-shirabe-fcef25f6ef36287a4984ffdaab39df84f5aceeba.tar.zst php-shirabe-fcef25f6ef36287a4984ffdaab39df84f5aceeba.zip | |
refactor(php-shim): split lib.rs
Diffstat (limited to 'crates/shirabe-php-shim/src/math.rs')
| -rw-r--r-- | crates/shirabe-php-shim/src/math.rs | 33 |
1 files changed, 33 insertions, 0 deletions
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 +} |
