File: exceptions.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 (54 lines) | stat: -rwxr-xr-x 1,377 bytes parent folder | download | duplicates (7)
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
48
49
50
51
52
53
54
use strict;
use warnings;
use Math::MPFR qw(:mpfr);

print "1..7\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 $x = Rmpfr_init();
my $y = Rmpfr_init();

if(Rmpfr_underflow_p() || Rmpfr_overflow_p() || Rmpfr_inexflag_p() ||
   Rmpfr_nanflag_p() || Rmpfr_erangeflag_p()) {print "not ok 1\n"}
else {print "ok 1\n"}

Rmpfr_add($y, $y, $y, GMP_RNDN);
if(Rmpfr_nanflag_p()) {print "ok 2\n"}
else {print "not ok 2\n"}

Rmpfr_set_ui($x, 2, GMP_RNDN);
Rmpfr_cos($x, $x, GMP_RNDN);
if(Rmpfr_inexflag_p()) {print "ok 3\n"}
else {print "not ok 3\n"}

Rmpfr_set_ui($x, 1, GMP_RNDN);
Rmpfr_mul_2exp($x, $x, 1024, GMP_RNDN);
Rmpfr_get_ui($x, GMP_RNDN);
if(Rmpfr_erangeflag_p()) {print "ok 4\n"}
else {print "not ok 4\n"}

Rmpfr_set_emin(-1020);
Rmpfr_set_emax(1020);

Rmpfr_set_ui($x, 1, GMP_RNDN);
Rmpfr_mul_2exp($x, $x, 1025, GMP_RNDN);
if(Rmpfr_overflow_p()) {print "ok 5\n"}
else {print "not ok 5\n"}

Rmpfr_set_ui($x, 1, GMP_RNDN);
Rmpfr_div_2exp($x, $x, 1025, GMP_RNDN);
if(Rmpfr_underflow_p()) {print "ok 6\n"}
else {print "not ok 6\n"}

Rmpfr_clear_flags();

if(Rmpfr_underflow_p() || Rmpfr_overflow_p() || Rmpfr_inexflag_p() ||
   Rmpfr_nanflag_p() || Rmpfr_erangeflag_p()) {print "not ok 7\n"}
else {print "ok 7\n"}