Ask Your Question

Revision history [back]

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, you can use the nosci option of the str method:

sage: a = 4.54645 
sage: a.str(no_sci=2, skip_zeroes=True)
'4.54645'

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, result (your second example), you can use the nosci option of the str method:

sage: a = 4.54645 
403455345.556 * 5
sage: a.str(no_sci=2, skip_zeroes=True)
'4.54645'
'2017276727.78'