Add 'round' function to builtin math

This commit is contained in:
ridiculousfish 2018-12-01 13:25:00 -08:00
parent 1785af156b
commit 5012fb0e36
4 changed files with 17 additions and 0 deletions

View file

@ -150,6 +150,7 @@ static const te_variable functions[] = {
{"npr", npr, TE_FUNCTION2 | TE_FLAG_PURE, 0},
{"pi", pi, TE_FUNCTION0 | TE_FLAG_PURE, 0},
{"pow", pow, TE_FUNCTION2 | TE_FLAG_PURE, 0},
{"round", round, TE_FUNCTION1 | TE_FLAG_PURE, 0},
{"sin", sin, TE_FUNCTION1 | TE_FLAG_PURE, 0},
{"sinh", sinh, TE_FUNCTION1 | TE_FLAG_PURE, 0},
{"sqrt", sqrt, TE_FUNCTION1 | TE_FLAG_PURE, 0},

View file

@ -2,6 +2,9 @@
####################
# Validate basic expressions
####################
# Validate some rounding functions
####################
# Validate some integral computations

View file

@ -15,6 +15,10 @@ math 5 \* -2
math -- -4 / 2
math -- '-4 * 2'
logmsg Validate some rounding functions
math 'round(3/2)' ; math 'floor(3/2)' ; math 'ceil(3/2)'
math 'round(-3/2)' ; math 'floor(-3/2)' ; math 'ceil(-3/2)'
logmsg Validate some integral computations
math 1
math 10

View file

@ -17,6 +17,15 @@
-2
-8
####################
# Validate some rounding functions
2
1
2
-2
-2
-1
####################
# Validate some integral computations
1