#2899: Make RDF round and friends return Integers
----------------------+-----------------------------------------------------
Reporter: jason | Owner: robertwb
Type: defect | Status: reopened
Priority: major | Milestone: sage-4.0.1
Component: coercion | Resolution:
Keywords: |
----------------------+-----------------------------------------------------
Comment(by ncalexan):
There are doctests for RDF for sure:
{{{
def round(self):
"""
Given real number x, rounds up if fractional part is greater than
.5, rounds down if fractional part is less than .5.
EXAMPLES::
sage: RDF(0.49).round()
0
sage: a=RDF(0.51).round(); a
1
"""
return Integer(round(self._value))
def floor(self):
"""
Returns the floor of this number
EXAMPLES::
sage: RDF(2.99).floor()
2
sage: RDF(2.00).floor()
2
sage: RDF(-5/2).floor()
-3
"""
return Integer(math.floor(self._value))
def ceil(self):
"""
Returns the ceiling of this number
OUTPUT: integer
EXAMPLES::
sage: RDF(2.99).ceil()
3
sage: RDF(2.00).ceil()
2
sage: RDF(-5/2).ceil()
-2
"""
return Integer(math.ceil(self._value))
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/2899#comment:7>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of
Reinventing the Wheel
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---