to answer the original question, here is how we can decompose in Sage a
35-digit constant into three 53-bit floating-point values:

sage: R120 = RealField(120)
sage: R53 = RealField(53)
sage: x = R120(pi)
sage: x
3.1415926535897932384626433832795029
sage: a = R53(x) # extracts the 53 most significant bits of x
sage: a.exact_rational()
884279719003555/281474976710656
sage: r = x - R120(a)
sage: r
1.2246467991473531772315719253130892e-16
sage: b = R53(r)
sage: b.exact_rational()
4967757600021511/40564819207303340847894502572032
sage: r = r - R120(b)
sage: r
-2.9942192104145307402979657076125042e-33
sage: c = R53(r)
sage: c.exact_rational()
-995/332306998946228968225951765070086144

thus we have decomposed x into a + b + c. We can check it is correct:

sage: x.exact_rational() == a.exact_rational() + b.exact_rational() + 
c.exact_rational()
True

Paul Zimmermann

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to