aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-php-shim/src/math.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe-php-shim/src/math.rs')
-rw-r--r--crates/shirabe-php-shim/src/math.rs33
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
+}