ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 16 Sep 2016 11:00:09 -0500function for removing scientific notationhttp://ask.sagemath.org/question/34844/function-for-removing-scientific-notation/Hi!
If I calculate a big number, say 4.546456 * 1000000000 sage will give the answer 4.5465 x 10^9
Is there a way to not do this and instead force sage to give the answer 4546456000. I have tested the N()-function and it works sometimes but not every time. The N()-function will also give me problems when solving. If a use .N() when I try to solve a = 403455345.556 * 5 I get the answer a=(100863836389 / 50) and I want to get the result a = 2017276727.78.
If I'm correct, the answer in the form 1 x 10^7 is done with scientific notation and my basic question is then if there is a way to "revert/undo/remove" the scientific notation.
TL;DR = Is there a way or function for sage to give results as 10 000 000 instead of 1 x 10^7?
Thanks!Fri, 16 Sep 2016 09:23:04 -0500http://ask.sagemath.org/question/34844/function-for-removing-scientific-notation/Answer by tmonteil for <p>Hi!</p>
<p>If I calculate a big number, say 4.546456 * 1000000000 sage will give the answer 4.5465 x 10^9
Is there a way to not do this and instead force sage to give the answer 4546456000. I have tested the N()-function and it works sometimes but not every time. The N()-function will also give me problems when solving. If a use .N() when I try to solve a = 403455345.556 * 5 I get the answer a=(100863836389 / 50) and I want to get the result a = 2017276727.78.</p>
<p>If I'm correct, the answer in the form 1 x 10^7 is done with scientific notation and my basic question is then if there is a way to "revert/undo/remove" the scientific notation. </p>
<p>TL;DR = Is there a way or function for sage to give results as 10 000 000 instead of 1 x 10^7?</p>
<p>Thanks!</p>
http://ask.sagemath.org/question/34844/function-for-removing-scientific-notation/?answer=34845#post-id-34845In this particular case, you can make it an integer:
sage: a = 4.546456 * 1000000000
sage: a
4.54645600000000e9
sage: a.parent()
Real Field with 53 bits of precision
sage: ZZ(a)
4546456000
sage: ZZ(a).parent()
Integer Ring
In the more general case of non-integer result (your second example), you can use the `nosci` option of the `str` method:
sage: a = 403455345.556 * 5
sage: a.str(no_sci=2, skip_zeroes=True)
'2017276727.78'Fri, 16 Sep 2016 11:00:09 -0500http://ask.sagemath.org/question/34844/function-for-removing-scientific-notation/?answer=34845#post-id-34845