diff options
author | Kevin B Kenny <kennykb@acm.org> | 2008-10-05 21:27:07 (GMT) |
---|---|---|
committer | Kevin B Kenny <kennykb@acm.org> | 2008-10-05 21:27:07 (GMT) |
commit | d663ac8e9131b33c795b6a046e1114156c2062b8 (patch) | |
tree | 266c4bfba7075b162b65a6946b039a329be2607f /tests | |
parent | 19622ba06dd7658926d7bbe3b30ce0825a803792 (diff) | |
download | tcl-d663ac8e9131b33c795b6a046e1114156c2062b8.zip tcl-d663ac8e9131b33c795b6a046e1114156c2062b8.tar.gz tcl-d663ac8e9131b33c795b6a046e1114156c2062b8.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.test | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/expr.test b/tests/expr.test index d0aaadb..e51e4c1 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.73 2008/10/05 21:27:07 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 |