Ask Your Question
0

function for removing scientific notation

asked 2016-09-16 16:23:04 +0100

mmcarbs gravatar image

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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2016-09-16 18:00:09 +0100

tmonteil gravatar image

updated 2016-09-16 18:01:30 +0100

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'
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2016-09-16 16:23:04 +0100

Seen: 881 times

Last updated: Sep 16 '16