# 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!

edit retag close merge delete

Sort by » oldest newest most voted

In 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'

more