3 ###############################################################################
12 unshift @INC, '../lib';
16 use bignum qw/oct hex/;
18 ###############################################################################
21 my $x = 5; ok (ref($x) =~ /^Math::BigInt/); # :constant
24 $x = 2 + 3.5; ok (ref($x),'Math::BigFloat');
26 $x = 2 + 2.1; ok (ref($x),'Math::BigFloat');
28 $x = 2 ** 255; ok (ref($x) =~ /^Math::BigInt/);
30 # see if Math::BigInt constant and upgrading works
31 ok (Math::BigInt::bsqrt('12'),'3.464101615137754587054892683011744733886');
32 ok (sqrt(12),'3.464101615137754587054892683011744733886');
34 ok (2/3,"0.6666666666666666666666666666666666666667");
36 #ok (2 ** 0.5, 'NaN'); # should be sqrt(2);
38 ok (12->bfac(),479001600);
40 # see if Math::BigFloat constant works
42 # 0123456789 0123456789 <- default 40
43 # 0123456789 0123456789
44 ok (1/3, '0.3333333333333333333333333333333333333333');
46 ###############################################################################
47 # accurarcy and precision
49 ok_undef (bignum->accuracy());
50 ok (bignum->accuracy(12),12);
51 ok (bignum->accuracy(),12);
53 ok_undef (bignum->precision());
54 ok (bignum->precision(12),12);
55 ok (bignum->precision(),12);
57 ok (bignum->round_mode(),'even');
58 ok (bignum->round_mode('odd'),'odd');
59 ok (bignum->round_mode(),'odd');
61 ###############################################################################
64 my $c = 'Math::BigInt';
67 ok (ref(hex(0x1)), $c);
68 ok (ref(hex("af")), $c);
69 ok (hex("af"), Math::BigInt->new(0xaf));
70 ok (ref(hex("0x1")), $c);
72 ok (ref(oct("0x1")), $c);
73 ok (ref(oct("01")), $c);
74 ok (ref(oct("0b01")), $c);
75 ok (ref(oct("1")), $c);
76 ok (ref(oct(" 1")), $c);
77 ok (ref(oct(" 0x1")), $c);
79 ok (ref(oct(0x1)), $c);
80 ok (ref(oct(01)), $c);
81 ok (ref(oct(0b01)), $c);
84 ###############################################################################
85 ###############################################################################
86 # Perl 5.005 does not like ok ($x,undef)
92 ok (1,1) and return if !defined $x;