summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKevin B Kenny <kennykb@acm.org>2011-07-02 22:36:45 (GMT)
committerKevin B Kenny <kennykb@acm.org>2011-07-02 22:36:45 (GMT)
commitab7a6af8cae45f25825b7c3ac24edc9af86c9233 (patch)
treecfb063e941efc61b9d4aaf5f1b223dae502e9b76 /tests
parent8f8741ac3a12f301cee5f84fd38210ef0527106c (diff)
parent59f60c354a264bd149bbe3248982f82c6ddd165a (diff)
downloadtcl-ab7a6af8cae45f25825b7c3ac24edc9af86c9233.zip
tcl-ab7a6af8cae45f25825b7c3ac24edc9af86c9233.tar.gz
tcl-ab7a6af8cae45f25825b7c3ac24edc9af86c9233.tar.bz2
Fix roundoff gaffe in bignum-to-double conversion [Bug 3349507]
Diffstat (limited to 'tests')
-rw-r--r--tests/util.test29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/util.test b/tests/util.test
index 1f214b5..d06925b 100644
--- a/tests/util.test
+++ b/tests/util.test
@@ -3858,6 +3858,35 @@ 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