File: test_mpfr_min_max.txt

package info (click to toggle)
python-gmpy2 2.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,628 kB
  • ctags: 1,123
  • sloc: ansic: 21,036; python: 5,846; makefile: 163
file content (57 lines) | stat: -rw-r--r-- 1,176 bytes parent folder | download | duplicates (5)
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
55
56
57
Testing of mpfr maxnum and minnum functions
-------------------------------------------

    >>> import gmpy2
    >>> from gmpy2 import mpz, mpq, mpfr, maxnum, minnum
    >>> a = mpfr("12.34")
    >>> b = mpfr("45.67")
    >>> nan = mpfr("nan")
    >>> inf = mpfr("inf")
    >>> minf = mpfr("-inf")

Test maxnum
-----------

    >>> maxnum(a,b)
    mpfr('45.670000000000002')
    >>> maxnum(b,a)
    mpfr('45.670000000000002')
    >>> maxnum(a,-b)
    mpfr('12.34')
    >>> maxnum(a, 123456)
    mpfr('123456.0')
    >>> maxnum(12345678901234567890, a)
    mpfr('1.2345678901234567e+19')
    >>> maxnum(0, -1)
    mpfr('0.0')
    >>> maxnum(1, inf)
    mpfr('inf')
    >>> maxnum(1, -inf)
    mpfr('1.0')
    >>> maxnum(nan, a)
    mpfr('12.34')
    >>> maxnum(a, nan)
    mpfr('12.34')
    >>> maxnum(nan, inf)
    mpfr('inf')
    >>> maxnum(nan, -inf)
    mpfr('-inf')
    >>> maxnum(nan, nan)
    mpfr('nan')

Test minnum
-----------

    >>> minnum(a,b)
    mpfr('12.34')
    >>> minnum(b,a)
    mpfr('12.34')
    >>> minnum(1,inf)
    mpfr('1.0')
    >>> minnum(minf, a)
    mpfr('-inf')
    >>> minnum(nan, inf)
    mpfr('inf')
    >>> minnum(nan, nan)
    mpfr('nan')