summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKevin B Kenny <kennykb@acm.org>2008-10-05 21:25:23 (GMT)
committerKevin B Kenny <kennykb@acm.org>2008-10-05 21:25:23 (GMT)
commit7a8890b848e2ed877f22708fa8aeebf5c22b129a (patch)
tree4e5b2800c54f1cd9167bea20db0760443baa0d39 /tests
parent6baa5b8d5a6b70470cad4964945c2027b381011f (diff)
downloadtcl-7a8890b848e2ed877f22708fa8aeebf5c22b129a.zip
tcl-7a8890b848e2ed877f22708fa8aeebf5c22b129a.tar.gz
tcl-7a8890b848e2ed877f22708fa8aeebf5c22b129a.tar.bz2
* libtommath/bn_mp_sqrt.c (bn_mp_sqrt): Handle the case where
* tests/expr.test (expr-47.13): a number's square root is between n<<DIGIT_BIT and n<<DIGIT_BIT+1. [Bug 2143288] Thanks to Malcolm Boffey (malcolm.boffey@virgin.net) for the patch.
Diffstat (limited to 'tests')
-rw-r--r--tests/expr.test23
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/expr.test b/tests/expr.test
index d0aaadb..30aebc6 100644
--- a/tests/expr.test
+++ b/tests/expr.test
@@ -10,7 +10,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: expr.test,v 1.72 2008/03/10 16:18:55 dgp Exp $
+# RCS: @(#) $Id: expr.test,v 1.72.2.1 2008/10/05 21:25:23 kennykb Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2.1
@@ -6770,6 +6770,7 @@ test expr-47.11 {isqrt of zero} {
test expr-47.12 {isqrt of various sizes of integer} {
set faults 0
+ set trouble {}
for {set i 0} {$faults < 10 && $i <= 1024} {incr i} {
set root [expr {1 << $i}]
set rm1 [expr {$root - 1}]
@@ -6796,6 +6797,26 @@ test expr-47.12 {isqrt of various sizes of integer} {
set trouble
} {}
+test expr-47.13 {isqrt and floating point rounding (Bug 2143288)} {
+ set trouble {}
+ set faults 0
+ for {set i 0} {$i < 29 && $faults < 10} {incr i} {
+ for {set j 0} {$j <= $i} {incr j} {
+ set k [expr {isqrt((1<<56)+(1<<$i)+(1<<$j))}]
+ if {$k != (1<<28)} {
+ append trouble "i = $i, j = $j, k = $k\n"
+ incr faults
+ }
+ }
+ set k [expr {isqrt((1<<56)+(1<<29)+(1<<$i))}]
+ if {$k != (1<<28)+1} {
+ append trouble "i = $i, k = $k\n"
+ incr faults
+ }
+ }
+ set trouble
+} {}
+
test expr-48.1 {Bug 1770224} {
expr {-0x8000000000000001 >> 0x8000000000000000}
} -1