Commit | Line | Data |
bce28014 |
1 | #!/usr/bin/perl -w |
2 | |
3 | ############################################################################### |
4 | # test for bug #18025: bignum/bigrat can lead to a number that is both 1 and 0 |
5 | |
6 | use Test::More; |
7 | use strict; |
8 | |
9 | BEGIN |
10 | { |
11 | $| = 1; |
12 | chdir 't' if -d 't'; |
13 | unshift @INC, '../lib'; |
14 | plan tests => 4; |
15 | } |
16 | |
17 | use bignum; |
18 | |
19 | my $lnev = -7 / (10**17); |
20 | my $ev=exp($lnev); |
21 | |
22 | is( sprintf('%0.5f',$ev) , '1.00000', '($ev) is approx. 1' ); |
23 | is( sprintf('%0.5f',1-$ev) , '0.00000', '(1-$ev) is approx. 0' ); |
24 | is( sprintf('%0.5f',1-"$ev") , '0.00000', '(1-"$ev") is approx. 0' ); |
25 | |
26 | cmp_ok( $ev, '!=', 0, '$ev should not equal 0'); |