diff --git a/Math.ark b/Math.ark index 1f44dc6..e799638 100644 --- a/Math.ark +++ b/Math.ark @@ -129,4 +129,15 @@ # =end ## (let math:log10 (fun (x) { - (math:log x 10)})) \ No newline at end of file + (math:log x 10)})) + +### +# @brief Returns the quotient of the euclidian division of a and b +# @param a the dividend +# @param b the divisor +# @author https://github.com/fabien-zoccola +# =begin +# (math:floordiv 14 6) # Returns 2 +# =end +## +(let math:floordiv (fun (a b) (math:floor (/ a b)))) \ No newline at end of file diff --git a/tests/math-tests.ark b/tests/math-tests.ark index 1c28920..a108c32 100644 --- a/tests/math-tests.ark +++ b/tests/math-tests.ark @@ -32,6 +32,9 @@ (set tests (assert-eq (math:log2 128) 7 "math:log2" tests)) (set tests (assert-eq (math:log2 2048) 11 "math:log2" tests)) (set tests (assert-eq (math:log10 1000) 3 "math:log10" tests)) + (set tests (assert-eq (math:floordiv 14 6) 2 "math:floordiv" tests)) + (set tests (assert-eq (math:floordiv 14 14) 1 "math:floordiv" tests)) + (set tests (assert-eq (math:floordiv 14 15) 0 "math:floordiv" tests)) (recap "Math tests passed" tests (- (time) start-time))