File: bigratup.t

package info (click to toggle)
perl 5.42.0-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 128,392 kB
  • sloc: perl: 534,963; ansic: 240,563; sh: 72,042; pascal: 6,934; xml: 2,428; yacc: 1,360; makefile: 1,197; cpp: 208; lisp: 1
file content (41 lines) | stat: -rw-r--r-- 848 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# -*- mode: perl; -*-

# Test whether $Math::BigInt::upgrade breaks our neck

use strict;
use warnings;

use Test::More tests => 5;

use Math::BigInt upgrade => 'Math::BigRat';
use Math::BigRat;

my $rat = 'Math::BigRat';
my($x, $y, $z);

##############################################################################
# bceil/bfloor

$x = $rat->new('49/4');
is($x->bfloor(), '12', 'floor(49/4)');

$x = $rat->new('49/4');
is($x->bceil(), '13', 'ceil(49/4)');

##############################################################################
# bsqrt

$x = $rat->new('144');
is($x->bsqrt(), '12', 'bsqrt(144)');

$x = $rat->new('144/16');
is($x->bsqrt(), '3', 'bsqrt(144/16)');

$x = $rat->new('1/3');
is($x->bsqrt(),
   '1443375672974064411272871951254893639119/2500000000000000000000000000000000000000',
   'bsqrt(1/3)');

# all tests successful

1;