summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKevin B Kenny <kennykb@acm.org>2011-07-02 21:56:33 (GMT)
committerKevin B Kenny <kennykb@acm.org>2011-07-02 21:56:33 (GMT)
commit59f60c354a264bd149bbe3248982f82c6ddd165a (patch)
tree32125ee4763fe4e82d3a6f93e806e3328c1fade5 /tests
parentab9198a4a8bfe2f03879c8fc4ae46b5f8eb64d60 (diff)
downloadtcl-59f60c354a264bd149bbe3248982f82c6ddd165a.zip
tcl-59f60c354a264bd149bbe3248982f82c6ddd165a.tar.gz
tcl-59f60c354a264bd149bbe3248982f82c6ddd165a.tar.bz2
Fix roundoff gaffe in bignum-to-double conversion [Bug 3349507]
Diffstat (limited to 'tests')
-rw-r--r--tests/util.test33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/util.test b/tests/util.test
index 7e3f962..6a0785e 100644
--- a/tests/util.test
+++ b/tests/util.test
@@ -3853,7 +3853,40 @@ test util-16.1.17.307 {8.4 compatible formatting of doubles} \
{expr 1e307} \
9.9999999999999999e+306
+test util-17.1 {bankers' rounding [Bug 3349507]} {ieeeFloatingPoint} {
+ set r {}
+ foreach {input} {
+ 0x1ffffffffffffc000
+ 0x1ffffffffffffc800
+ 0x1ffffffffffffd000
+ 0x1ffffffffffffd800
+ 0x1ffffffffffffe000
+ 0x1ffffffffffffe800
+ 0x1fffffffffffff000
+ 0x1fffffffffffff800
+ } {
+ binary scan [binary format q [expr double($input)]] wu x
+ lappend r [format %#llx $x]
+ binary scan [binary format q [expr double(-$input)]] wu x
+ lappend r [format %#llx $x]
+ }
+ set r
+} [list {*}{
+ 0x43fffffffffffffc 0xc3fffffffffffffc
+ 0x43fffffffffffffc 0xc3fffffffffffffc
+ 0x43fffffffffffffd 0xc3fffffffffffffd
+ 0x43fffffffffffffe 0xc3fffffffffffffe
+ 0x43fffffffffffffe 0xc3fffffffffffffe
+ 0x43fffffffffffffe 0xc3fffffffffffffe
+ 0x43ffffffffffffff 0xc3ffffffffffffff
+ 0x4400000000000000 0xc400000000000000
+}]
+
set ::tcl_precision $saved_precision
# cleanup
::tcltest::cleanupTests
return
+
+# Local Variables:
+# mode: tcl
+# End: \ No newline at end of file