ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 13 Jan 2020 23:24:53 +0100Unable to convert string to rational when plus sign is addedhttps://ask.sagemath.org/question/49537/unable-to-convert-string-to-rational-when-plus-sign-is-added/This looks like a bug. The code
QQ('+1')
gives the exception
> TypeError: unable to convert '+1' to a
> rational
This happens with any positive rational, not just 1.
Also, this does not happen with neither
ZZ('+1')
nor
PolynomialRing(QQ,names='x')('+1')
Is this actually a bug? If it is, can someone investigate it and write a trac ticket? I'm quite new to Sagemath and Python and quite unskilled yet to do it properly. Thank you!Jose BroxMon, 13 Jan 2020 23:24:53 +0100https://ask.sagemath.org/question/49537/Converting string into number does not work properlyhttps://ask.sagemath.org/question/9034/converting-string-into-number-does-not-work-properly/Here is an example with huge integer number "n".
n=2^7000000;
Sage can convert huge integer number into string very quickly:
s=str(n);
But the other way, i.e. the same huge string converting back into integer number is very slow:
m=int(s);
It should be done in approximately same time as variables "m", "n", "s" are of the same length.
I also tried to use eval(s) and sage_eval(s) instead of int(s) and all are very slow.
Mathematica can do all the above operation much more quickly than Sage.
Do you know, where the problem is?
Is there some other function besides "int", "eval" and "sage_eval" that can do it faster?azerbajdzanWed, 06 Jun 2012 08:02:20 +0200https://ask.sagemath.org/question/9034/