# Ticket #4036: trac_4036-3.patch

File trac_4036-3.patch, 1.8 KB (added by Mike Hansen, 14 years ago)
• ## sage/interfaces/axiom.py

```# HG changeset patch
# User Mike Hansen <mhansen@gmail.com>
# Date 1220839712 25200
# Node ID f87f24bf93dacfef3fbb2f0bf1e57ff877c6f8e9
# Parent  a095499e2103d028aaffe83635f19305b6fc77ae
Improve how floats are converted from Axiom to Sage.

diff -r a095499e2103 -r f87f24bf93da sage/interfaces/axiom.py```
 a Real Double Field sage: RealField(68)((2.1234).exact_rational()) 2.1234000000000001762 sage: axiom(2.1234)._sage_() #optional 2.1234000000000001762 2.12340000000000 sage: _.parent()             #optional Real Field with 68 bits of precision Real Field with 53 bits of precision sage: a = RealField(100)(pi) sage: axiom(a)._sage_()      #optional 3.1415926535897932384626433833 sage: _.parent()             #optional Real Field with 100 bits of precision sage: axiom(a)._sage_() == a #optional True sage: axiom(2.0)._sage_() #optional 2.00000000000000 sage: _.parent() #optional Real Field with 53 bits of precision We can also convert Axiom's polynomials to Sage polynomials. if type == "Float": from sage.rings.all import RealField, ZZ prec = P('precision()\$Float')._sage_() prec = max(self.mantissa().length()._sage_(), 53) R = RealField(prec) x,e,b = self.unparsed_input_form().lstrip('float(').rstrip(')').split(',') return R(ZZ(x)*ZZ(b)**ZZ(e))