diff --git a/program/function_definition.go b/program/function_definition.go index 848bf2775..eed041fe5 100644 --- a/program/function_definition.go +++ b/program/function_definition.go @@ -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", diff --git a/tests/math.c b/tests/math.c index 4f7675501..bbda2d36c 100644 --- a/tests/math.c +++ b/tests/math.c @@ -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 @@ -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);