Skip to content

Commit

Permalink
convert round calls to math.Round
Browse files Browse the repository at this point in the history
  • Loading branch information
icholy committed Jul 10, 2018
1 parent 7985ea8 commit adb04f9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
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(doube) -> 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

0 comments on commit adb04f9

Please sign in to comment.