xref: /openbsd/gnu/usr.bin/perl/cpan/bignum/t/bigexp.t (revision 3bef86f7)
1# -*- mode: perl; -*-
2
3###############################################################################
4# test for bug #18025: bigfloat/bigrat can lead to a number that is both 1 and 0
5
6use strict;
7use warnings;
8
9use Test::More tests => 4;
10
11use bigfloat;
12
13my $ln_ev = -7 / (10 ** 17);
14my $ev    = exp($ln_ev);
15is(sprintf('%0.5f', $ev),       '1.00000', '($ev) is approx. 1');
16is(sprintf('%0.5f', 1 - $ev),   '0.00000', '(1-$ev) is approx. 0');
17is(sprintf('%0.5f', 1 - "$ev"), '0.00000', '(1-"$ev") is approx. 0');
18
19cmp_ok($ev, '!=', 0, '$ev should not equal 0');
20