diff options
author | Kevin B Kenny <kennykb@acm.org> | 2011-07-02 21:56:33 (GMT) |
---|---|---|
committer | Kevin B Kenny <kennykb@acm.org> | 2011-07-02 21:56:33 (GMT) |
commit | e08b947885c19c9ce8dc19999af8b96fb3d37073 (patch) | |
tree | 32125ee4763fe4e82d3a6f93e806e3328c1fade5 /tests/util.test | |
parent | 9bad349b17ac966a8c3e2633ada87723d34e69b9 (diff) | |
download | tcl-e08b947885c19c9ce8dc19999af8b96fb3d37073.zip tcl-e08b947885c19c9ce8dc19999af8b96fb3d37073.tar.gz tcl-e08b947885c19c9ce8dc19999af8b96fb3d37073.tar.bz2 |
Fix roundoff gaffe in bignum-to-double conversion [Bug 3349507]
Diffstat (limited to 'tests/util.test')
-rw-r--r-- | tests/util.test | 33 |
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 |