First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Toy solution :

  • Create an example :

    sage: # Let's generate (the string representation of) a large integer sage: foo=str(frac(pi).n(digits=3000)) sage: # Put that (except the initial "0.") on a file sage: f=open("pifrac.txt", "w", encoding="utf8") sage: f.write("%s\n"%foo[2:]) 3001 sage: f.close()

  • Read that string :

    sage: # Read that back in a string sage: f=open("pifrac.txt", "r", encoding="utf8") sage: bar=f.readline() sage: f.close()

  • Convert it :

    sage: gee=eval("Integer(%s)"%bar)

  • Check it :

    sage: # What's that ? sage: type(gee) <class 'sage.rings.integer.integer'=""> sage: # Magnitude ? sage: gee.log(10).n() 2999.15104072095

  • Check again :

    sage: (frac(pi).n(digits=3000)-gee*1e-3000).log(10) -infinity

Right...

HTH,

click to hide/show revision 2
No.2 Revision

Toy solution :

  • Create an example :

    sage: # Let's generate (the string representation of) a large integer 
    sage: foo=str(frac(pi).n(digits=3000))
    sage: # Put that (except the initial "0.") on a file
    sage: f=open("pifrac.txt", "w", encoding="utf8")
    sage: f.write("%s\n"%foo[2:])
    3001
    sage: f.close()

  • f.close()
  • Read that string :

    sage: # Read that back in a string
    sage: f=open("pifrac.txt", "r", encoding="utf8")
    sage: bar=f.readline()
    sage: f.close()

  • f.close()
  • Convert it :

    sage: gee=eval("Integer(%s)"%bar)

  • gee=eval("Integer(%s)"%bar)
  • Check it :

    sage: # What's that ?
    sage: type(gee)
    <class 'sage.rings.integer.integer'="">
    'sage.rings.integer.Integer'>
    sage: # Magnitude ?
    sage: gee.log(10).n()
    2999.15104072095

  • 2999.15104072095
  • Check again :

    sage: (frac(pi).n(digits=3000)-gee*1e-3000).log(10)
    -infinity

-infinity

Right...

HTH,