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 b  
    724724            Real Double Field
    725725
    726726
    727             sage: RealField(68)((2.1234).exact_rational())
    728             2.1234000000000001762
    729727            sage: axiom(2.1234)._sage_() #optional
    730             2.1234000000000001762
     728            2.12340000000000
    731729            sage: _.parent()             #optional
    732             Real Field with 68 bits of precision
     730            Real Field with 53 bits of precision
     731            sage: a = RealField(100)(pi)
     732            sage: axiom(a)._sage_()      #optional
     733            3.1415926535897932384626433833
     734            sage: _.parent()             #optional
     735            Real Field with 100 bits of precision
     736            sage: axiom(a)._sage_() == a #optional
     737            True
     738            sage: axiom(2.0)._sage_() #optional
     739            2.00000000000000
     740            sage: _.parent() #optional
     741            Real Field with 53 bits of precision
    733742
    734743
    735744        We can also convert Axiom's polynomials to Sage polynomials.
     
    755764       
    756765        if type == "Float":
    757766            from sage.rings.all import RealField, ZZ
    758             prec = P('precision()$Float')._sage_()
     767            prec = max(self.mantissa().length()._sage_(), 53)
    759768            R = RealField(prec)
    760769            x,e,b = self.unparsed_input_form().lstrip('float(').rstrip(')').split(',')
    761770            return R(ZZ(x)*ZZ(b)**ZZ(e))