On Thu, Mar 29, 2018 at 11:56 AM, Nils Bruin <nbr...@sfu.ca> wrote: > On Thursday, March 29, 2018 at 10:37:03 AM UTC-7, William wrote: >> >> >> It's surprisingly easy to implement this, due to how Robert Bradshaw >> rewrote this part of the Sage preparser. If you define this >> function in a notebook or command line sage session: >> >> def RealNumber(s): >> if '.' not in s: >> return QQ(s) >> a = s.split('.') >> return ZZ(a[0]) + ZZ(a[1])/10^len(a[1]) >> >> then all real number literals will be interpreted as exact rationals! >> > Cool! it does require slightly more complicated string mangling to work in > general, though: > > sage: 1.3e5 > TypeError: unable to convert '3e5' to a rational
Thanks -- I should have added that the above was a quick "proof of concept". William -- William (http://wstein.org) -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.