Ask Your Question

Revision history [back]

A real interval field element is a pair of real numbers (lower and upper)

sage: a = RIF(pi)
sage: a.lower()
3.14159265358979
sage: a.upper()
3.14159265358980
sage: b = RIF(3.24, 5.4)
sage: b.lower()
3.24000000000000
sage: b.upper()
5.40000000000001

You can see above that the interval is not necessarily small! And you can check that applying floor not necessarily leads to a unique possibility

sage: b.floor()
4.?
sage: b.floor().lower()
3.00000000000000
sage: b.floor().upper()
5.00000000000000

If you want to go from a real interval field to an integer there are the following methods

sage: a.unique_floor()
3
sage: a.unique_ceil()
4
sage: c = RIF(2.9, 3.1)
sage: c.unique_integer()
3

These method might give errors when not appropriate

sage: a.unique_integer()
Traceback (most recent call last):
...
ValueError: interval contains no integer
sage: b.unique_floor()
Traceback (most recent call last):
...
ValueError: interval does not have a unique floor

A real interval field element is a pair of real numbers (lower and upper)

sage: a = RIF(pi)
sage: a.lower()
3.14159265358979
sage: a.upper()
3.14159265358980
sage: b = RIF(3.24, 5.4)
sage: b.lower()
3.24000000000000
sage: b.upper()
5.40000000000001

You can see above that the interval is not necessarily small! And you can check that applying floor not necessarily leads to a unique possibility

sage: b.floor()
4.?
sage: b.floor().lower()
3.00000000000000
sage: b.floor().upper()
5.00000000000000

If you want to go from a real interval field to an integer there are the following methods

sage: a.unique_floor()
3
sage: a.unique_ceil()
4
sage: c = RIF(2.9, 3.1)
sage: c.unique_integer()
3

These method methods might give errors when not appropriate

sage: a.unique_integer()
Traceback (most recent call last):
...
ValueError: interval contains no integer
sage: b.unique_floor()
Traceback (most recent call last):
...
ValueError: interval does not have a unique floor