File: integer_string.t

package info (click to toggle)
libmath-mpfr-perl 4.46-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,744 kB
  • sloc: perl: 1,533; ansic: 517; makefile: 9
file content (47 lines) | stat: -rwxr-xr-x 1,411 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
42
43
44
45
46
47
use warnings;
use strict;
use Math::MPFR qw(:mpfr);

print "1..1\n";

print  "# Using Math::MPFR version ", $Math::MPFR::VERSION, "\n";
print  "# Using mpfr library version ", MPFR_VERSION_STRING, "\n";
print  "# Using gmp library version ", Math::MPFR::gmp_v(), "\n";

my $ok = '';

my $nan = Math::MPFR->new();

$ok .= 'a' if lc(Rmpfr_integer_string($nan, 10, GMP_RNDN)) eq 'nan';

my ($man, $exp) = Rmpfr_deref2($nan, 10, 0, GMP_RNDN);

$ok .= 'b' if lc($man) eq '@nan@';

my $one = Math::MPFR->new(1);
my $minus_one = Math::MPFR->new(-1);
my $zero = Math::MPFR->new(0);
my $minus_zero = Math::MPFR->new(-0.0);

my $inf = $one / $zero;
$ok .= 'c' if lc(Rmpfr_integer_string($inf, 10, GMP_RNDN)) eq 'inf';

$inf = $minus_one / $minus_zero;
$ok .= 'd' if lc(Rmpfr_integer_string($inf, 10, GMP_RNDN)) eq 'inf';

$inf = $one / $minus_zero;
$ok .= 'e' if lc(Rmpfr_integer_string($inf, 10, GMP_RNDN)) eq '-inf';

$inf = $minus_one / $zero;
$ok .= 'f' if lc(Rmpfr_integer_string($inf, 10, GMP_RNDN)) eq '-inf';

$ok .= 'g' if Rmpfr_integer_string($zero, 10, GMP_RNDN) eq '0';
$ok .= 'h' if Rmpfr_integer_string($minus_zero, 10, GMP_RNDN) eq '-0';

my $minus_zero2 = Math::MPFR->new(-0);
$ok .= 'i' if Rmpfr_integer_string($minus_zero2, 10, GMP_RNDN) eq '0';
$ok .= 'j' if lc(Rmpfr_integer_string($zero / $minus_zero, 10, GMP_RNDN)) eq 'nan';

if($ok eq 'abcdefghij') {print "ok 1\n"}
else {print "not ok 1 $ok\n"}