Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(std): std math functions. #384

Merged
Merged
Changes from 1 commit
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
Prev Previous commit
fix(shellcheck)
  • Loading branch information
MuhamedMagdi committed Jul 31, 2024
commit 13ad92483d3a6783900dfaf1e008634543fba937
4 changes: 2 additions & 2 deletions src/std/math.ab
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ pub fun sum(list: [Num]): Num {
/// Returns the number rounded to the nearest integer
#[allow_absurd_cast]
pub fun round(number: Num): Num {
return unsafe $printf "%0.f" {number}$ as Num
return unsafe $printf "%0.f" "{number}"$ as Num
}

/// Returns the largest integer less than or equal to the number
#[allow_absurd_cast]
pub fun floor(number: Num): Num {
return unsafe $echo {number} | awk '\{printf "%d", (\$1 < 0 ? int(\$1) - 1 : int(\$1))}'$ as Num
return unsafe $echo "{number}" | awk '\{printf "%d", (\$1 < 0 ? int(\$1) - 1 : int(\$1))}'$ as Num
b1ek marked this conversation as resolved.
Show resolved Hide resolved
}

/// Returns the smallest integer greater than or equal to the number
Expand Down