math.functions: remove round-to.
parent
dc27c21ab0
commit
360c2ee5a7
|
@ -40,7 +40,6 @@ ARTICLE: "arithmetic-functions" "Arithmetic functions"
|
||||||
floor
|
floor
|
||||||
truncate
|
truncate
|
||||||
round
|
round
|
||||||
round-to
|
|
||||||
}
|
}
|
||||||
"Inexact comparison:"
|
"Inexact comparison:"
|
||||||
{ $subsections ~ }
|
{ $subsections ~ }
|
||||||
|
@ -333,15 +332,6 @@ HELP: round
|
||||||
{ $example "USING: math.functions prettyprint ;" "4.4 round ." "4.0" }
|
{ $example "USING: math.functions prettyprint ;" "4.4 round ." "4.0" }
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
HELP: round-to
|
|
||||||
{ $values { "x" real } { "n" integer } { "y" real } }
|
|
||||||
{ $description "Outputs the number closest to " { $snippet "x" } ", rounded to " { $snippet "n" } " decimals." }
|
|
||||||
{ $notes "The result is not necessarily an integer." }
|
|
||||||
{ $examples
|
|
||||||
{ $example "USING: math.functions prettyprint ;" "1.23456 2 round-to ." "1.23" }
|
|
||||||
{ $example "USING: math.functions prettyprint ;" "12345.6789 -3 round-to ." "12000.0" }
|
|
||||||
} ;
|
|
||||||
|
|
||||||
HELP: roots
|
HELP: roots
|
||||||
{ $values { "x" number } { "t" integer } { "seq" sequence } }
|
{ $values { "x" number } { "t" integer } { "seq" sequence } }
|
||||||
{ $description "Outputs the " { $snippet "t" } " roots of a number " { $snippet "x" } "." }
|
{ $description "Outputs the " { $snippet "t" } " roots of a number " { $snippet "x" } "." }
|
||||||
|
|
|
@ -260,19 +260,3 @@ CONSTANT: log10-factorial-1000 0x1.40f3593ed6f8ep11
|
||||||
{ -1.0 } [ -1 -0.0 copysign ] unit-test
|
{ -1.0 } [ -1 -0.0 copysign ] unit-test
|
||||||
{ 1.5 } [ -1.5 2 copysign ] unit-test
|
{ 1.5 } [ -1.5 2 copysign ] unit-test
|
||||||
{ -1.5 } [ -1.5 -2 copysign ] unit-test
|
{ -1.5 } [ -1.5 -2 copysign ] unit-test
|
||||||
|
|
||||||
{ 0.0 } [ 0 2 round-to ] unit-test
|
|
||||||
{ 1.0 } [ 1 2 round-to ] unit-test
|
|
||||||
{ 1.23 } [ 1.2349 2 round-to ] unit-test
|
|
||||||
{ 1.24 } [ 1.2350 2 round-to ] unit-test
|
|
||||||
{ 1.24 } [ 1.2351 2 round-to ] unit-test
|
|
||||||
{ -1.23 } [ -1.2349 2 round-to ] unit-test
|
|
||||||
{ -1.24 } [ -1.2350 2 round-to ] unit-test
|
|
||||||
{ -1.24 } [ -1.2351 2 round-to ] unit-test
|
|
||||||
{
|
|
||||||
{
|
|
||||||
0.0 0.0 10000.0 12000.0 12300.0 12350.0 12346.0 12345.7
|
|
||||||
12345.68 12345.679 12345.6789 12345.6789 12345.678901
|
|
||||||
12345.6789012 12345.67890123 12345.678901235
|
|
||||||
}
|
|
||||||
} [ 12345.67890123456 -6 9 [a,b] [ round-to ] with map ] unit-test
|
|
||||||
|
|
|
@ -406,6 +406,3 @@ M: float copysign
|
||||||
[ double>bits ] [ fp-sign ] bi*
|
[ double>bits ] [ fp-sign ] bi*
|
||||||
[ 63 2^ bitor ] [ 63 2^ bitnot bitand ] if
|
[ 63 2^ bitor ] [ 63 2^ bitnot bitand ] if
|
||||||
bits>double ;
|
bits>double ;
|
||||||
|
|
||||||
: round-to ( x n -- y )
|
|
||||||
10^ [ * 0.5 over 0 > [ + ] [ - ] if truncate ] [ / ] bi ;
|
|
||||||
|
|
Loading…
Reference in New Issue