#8336: round(x) <> x.round() for x in RealField
--------------------------------+-------------------------------------------
Reporter: zimmerma | Owner: robertwb
Type: defect | Status: needs_info
Priority: critical | Milestone: sage-4.6.1
Component: basic arithmetic | Keywords:
Author: | Upstream: N/A
Reviewer: | Merged:
Work_issues: |
--------------------------------+-------------------------------------------
Comment(by robertwb):
I don't think it should return a float of fixed precision, it just so
happened that the input was 53 bits.
What I want is round(x) to call x.round() and possibly
x.round(ndigits=ndigits), if available. Thus
{{{
sage: L = [RDF(pi), RealField(100)(pi), float(pi)]
sage: [x.round() for x in L if hasattr(x, 'round')]
[3, 3]
sage: [round(x) for x in L]
[3, 3, 3]
sage: [x.round(ndigits=2) for x in L if hasattr(x, 'round')]
[3.14, 3.1400000000000000000000000000]
sage: [round(x, ndigits=2) for x in L]
[3.14, 3.1400000000000000000000000000, 3.1400000000000001]
sage: [parent(round(x, ndigits=2)) is parent(x) for x in L]
[True, True, True]
}}}
Sometimes it seems it'd be quicker to just code this up than keep talking
about it :).
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/8336#comment:7>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
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.