3 ###############################################################################
12 unshift @INC, '../lib';
16 use bigrat qw/oct hex/;
18 ###############################################################################
21 my $x = 5; ok (ref($x) =~ /^Math::BigInt/); # :constant
23 # todo: ok (2 + 2.5,4.5); # should still work
24 # todo: $x = 2 + 3.5; ok (ref($x),'Math::BigFloat');
26 $x = 2 ** 255; ok (ref($x) =~ /^Math::BigInt/);
28 # see if Math::BigRat constant works
34 ok (3/7+1.1,'107/70');
38 ok (3/7-1.1,'-47/70');
44 ok (1.1+3/7,'107/70');
46 ok (3/7 / (5/7),'3/5');
50 ###############################################################################
51 # accurarcy and precision
53 ok_undef (bigrat->accuracy());
54 ok (bigrat->accuracy(12),12);
55 ok (bigrat->accuracy(),12);
57 ok_undef (bigrat->precision());
58 ok (bigrat->precision(12),12);
59 ok (bigrat->precision(),12);
61 ok (bigrat->round_mode(),'even');
62 ok (bigrat->round_mode('odd'),'odd');
63 ok (bigrat->round_mode(),'odd');
65 ###############################################################################
68 my $c = 'Math::BigInt';
71 ok (ref(hex(0x1)), $c);
72 ok (ref(hex("af")), $c);
73 ok (hex("af"), Math::BigInt->new(0xaf));
74 ok (ref(hex("0x1")), $c);
76 ok (ref(oct("0x1")), $c);
77 ok (ref(oct("01")), $c);
78 ok (ref(oct("0b01")), $c);
79 ok (ref(oct("1")), $c);
80 ok (ref(oct(" 1")), $c);
81 ok (ref(oct(" 0x1")), $c);
83 ok (ref(oct(0x1)), $c);
84 ok (ref(oct(01)), $c);
85 ok (ref(oct(0b01)), $c);
88 ###############################################################################
89 ###############################################################################
90 # Perl 5.005 does not like ok ($x,undef)
96 ok (1,1) and return if !defined $x;