mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-10 15:14:44 +00:00
Add 'round' function to builtin math
This commit is contained in:
parent
1785af156b
commit
5012fb0e36
4 changed files with 17 additions and 0 deletions
|
@ -150,6 +150,7 @@ static const te_variable functions[] = {
|
||||||
{"npr", npr, TE_FUNCTION2 | TE_FLAG_PURE, 0},
|
{"npr", npr, TE_FUNCTION2 | TE_FLAG_PURE, 0},
|
||||||
{"pi", pi, TE_FUNCTION0 | TE_FLAG_PURE, 0},
|
{"pi", pi, TE_FUNCTION0 | TE_FLAG_PURE, 0},
|
||||||
{"pow", pow, TE_FUNCTION2 | 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},
|
{"sin", sin, TE_FUNCTION1 | TE_FLAG_PURE, 0},
|
||||||
{"sinh", sinh, TE_FUNCTION1 | TE_FLAG_PURE, 0},
|
{"sinh", sinh, TE_FUNCTION1 | TE_FLAG_PURE, 0},
|
||||||
{"sqrt", sqrt, TE_FUNCTION1 | TE_FLAG_PURE, 0},
|
{"sqrt", sqrt, TE_FUNCTION1 | TE_FLAG_PURE, 0},
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
####################
|
####################
|
||||||
# Validate basic expressions
|
# Validate basic expressions
|
||||||
|
|
||||||
|
####################
|
||||||
|
# Validate some rounding functions
|
||||||
|
|
||||||
####################
|
####################
|
||||||
# Validate some integral computations
|
# Validate some integral computations
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,10 @@ math 5 \* -2
|
||||||
math -- -4 / 2
|
math -- -4 / 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
|
logmsg Validate some integral computations
|
||||||
math 1
|
math 1
|
||||||
math 10
|
math 10
|
||||||
|
|
|
@ -17,6 +17,15 @@
|
||||||
-2
|
-2
|
||||||
-8
|
-8
|
||||||
|
|
||||||
|
####################
|
||||||
|
# Validate some rounding functions
|
||||||
|
2
|
||||||
|
1
|
||||||
|
2
|
||||||
|
-2
|
||||||
|
-2
|
||||||
|
-1
|
||||||
|
|
||||||
####################
|
####################
|
||||||
# Validate some integral computations
|
# Validate some integral computations
|
||||||
1
|
1
|
||||||
|
|
Loading…
Reference in a new issue