Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Math.ark
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,15 @@
# =end
##
(let math:log10 (fun (x) {
(math:log x 10)}))
(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))))
3 changes: 3 additions & 0 deletions tests/math-tests.ark
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down