From 360c2ee5a792d628e6c54f64e8ec520ae6d1fbc9 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Mon, 1 Apr 2013 17:02:44 -0700 Subject: [PATCH] math.functions: remove round-to. --- basis/math/functions/functions-docs.factor | 10 ---------- basis/math/functions/functions-tests.factor | 16 ---------------- basis/math/functions/functions.factor | 3 --- 3 files changed, 29 deletions(-) diff --git a/basis/math/functions/functions-docs.factor b/basis/math/functions/functions-docs.factor index 0260a6f37c..f495dbcebb 100644 --- a/basis/math/functions/functions-docs.factor +++ b/basis/math/functions/functions-docs.factor @@ -40,7 +40,6 @@ ARTICLE: "arithmetic-functions" "Arithmetic functions" floor truncate round - round-to } "Inexact comparison:" { $subsections ~ } @@ -333,15 +332,6 @@ HELP: round { $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 { $values { "x" number } { "t" integer } { "seq" sequence } } { $description "Outputs the " { $snippet "t" } " roots of a number " { $snippet "x" } "." } diff --git a/basis/math/functions/functions-tests.factor b/basis/math/functions/functions-tests.factor index 23568897ff..5063040ae5 100644 --- a/basis/math/functions/functions-tests.factor +++ b/basis/math/functions/functions-tests.factor @@ -260,19 +260,3 @@ CONSTANT: log10-factorial-1000 0x1.40f3593ed6f8ep11 { -1.0 } [ -1 -0.0 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 diff --git a/basis/math/functions/functions.factor b/basis/math/functions/functions.factor index b540d2b242..29b10a49c7 100644 --- a/basis/math/functions/functions.factor +++ b/basis/math/functions/functions.factor @@ -406,6 +406,3 @@ M: float copysign [ double>bits ] [ fp-sign ] bi* [ 63 2^ bitor ] [ 63 2^ bitnot bitand ] if bits>double ; - -: round-to ( x n -- y ) - 10^ [ * 0.5 over 0 > [ + ] [ - ] if truncate ] [ / ] bi ;