Default math scale to 6

This changes the behavior of builtin math to floating point by default.
If the result of a computation is an integer, then it will be printed as an
integer; otherwise it will be printed as a floating point decimal with up to
'scale' digits past the decimal point (default is 6, matching printf).
Trailing zeros are trimmed. Values are rounded following printf semantics.

Fixes #4478
This commit is contained in:
ridiculousfish
2018-07-24 00:00:06 -07:00
parent 78cac07d3c
commit d2bee105c9
5 changed files with 81 additions and 26 deletions

View File

@@ -2,6 +2,9 @@
####################
# Validate basic expressions
####################
# Validate some integral computations
####################
# Validate how variables in an expression are handled
@@ -24,7 +27,7 @@ math: Error: Too many arguments
^
math: Expected at least 1 args, got only 0
math: Expected at least 1 args, got only 0
math: Error: Result is too large
'2^650'
math: Error: Result is infinite
'2^999999'
math: Error: Result is infinite
'1 / 0'