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

Convert round calls to math.Round #777

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions program/function_definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ var builtInFunctionDefinitions = map[string][]string{
"double log(double) -> math.Log",
"double log10(double) -> math.Log10",
"double pow(double, double) -> math.Pow",
"double round(double) -> math.Round",
"double sin(double) -> math.Sin",
"double sinh(double) -> math.Sinh",
"double sqrt(double) -> math.Sqrt",
Expand Down
11 changes: 11 additions & 0 deletions tests/math.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,17 @@ int main()
is_nan(pow(-INFINITY, NAN));
is_nan(pow(NAN, NAN));

diag("round")
is_nan(round(NAN));
is_eq(round(INFINITY), INFINITY);
is_eq(round(-INFINITY), -INFINITY);
is_eq(round(0), 0);
is_eq(round(1), 1);
is_eq(round(0.5), 1);
is_eq(round(0.4), 0);
is_eq(round(1.23e300), 1.23e300);
is_eq(round(M_PI), 3);

diag("sin");
is_eq(sin(0), 0);
is_eq(sin(1), 0.84147098480789650488);
Expand Down