Skip to content
Open
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
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
17 changes: 16 additions & 1 deletion tests/math.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ unsigned long long ullmax = 18446744073709551615ull;

int main()
{
plan(359);
plan(372);

// Note: There are some tests that must be disabled because they return
// different values under different compilers. See the comment surrounding the
Expand Down Expand Up @@ -400,6 +400,21 @@ int main()
is_nan(pow(-INFINITY, NAN));
is_nan(pow(NAN, NAN));

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

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