Ticket #2472 (new defect)
what parent should floor return?
| Reported by: | ncalexan | Owned by: | somebody |
|---|---|---|---|
| Priority: | minor | Milestone: | sage-5.10 |
| Component: | basic arithmetic | Keywords: | floor truncate ceil ceiling parent integer |
| Cc: | ncalexan | Work issues: | |
| Report Upstream: | Reviewers: | ||
| Authors: | Merged in: | ||
| Dependencies: | Stopgaps: |
Description
I think floor and ceil and truncate should return integers.
sage: floor(2).parent() Integer Ring sage: floor(2.0).parent() Integer Ring sage: floor(RIF(2.0)).parent() Real Interval Field with 53 bits of precision
Change History
comment:2 Changed 5 years ago by cwitty
But what integer should it return? In particular, what do you want floor(RIF(1.5, 12345.678)) to return, and why?
My vote would be that floor and ceiling should not be implemented for RIF at all, because I don't think they have a sensible meaning.
Note that when William first implemented floor and ceiling for RIF, he had them return integers; but he immediately (38 minutes later, according to Mercurial) changed them to return intervals, calling this a '"moral" improvement'.
comment:3 Changed 5 years ago by dmharvey
Perhaps what we need is an IntegerInterval class which represents an interval in ZZ.
I think this might even have come up in the context of valuations of p-adic numbers, and I might have even discussed it with David Roe, but I can't remember if anything came out of it.

I agree, though this goes against what Python does:
I don't like Python's math.floor behavior, but I bet it agrees with the C library. Yep:
double floor(double x); long double floorl(long double x);I still vote for making floor always return Integer.