# Show full (non-scientific-notation) of very small decimal?

When I run:

1/(2^70).n()


Sage returns:

8.47032947254300e-22


How can I get it to instead show:

.000000000000000000000847032947254300

edit retag close merge delete

Sort by ยป oldest newest most voted

You can look at the no_sci option of the str method of a floating-point number:

sage: a = 1/(2^70).n()
sage: a
8.47032947254300e-22
sage: a.str(no_sci=2)
'0.000000000000000000000847032947254300'


To get the doc of the str method, you can do a.str?

more

( 2016-03-31 08:30:38 -0600 )edit

One possibility to get what you want is to use Python string formatting.

This can be done the old way with % and the new way with {}and .format. The old way will accept many types of numbers, the new way requires the entry to have the type of a Python float.

Here is an illustration of both, with 72 digits after the decimal point.

sage: a = 1/2^70
sage: '%.72f' % a
'0.000000000000000000000847032947254300339068322500679641962051391601562500'
sage: '{:.72f}'.format(float(a))
'0.000000000000000000000847032947254300339068322500679641962051391601562500'


Combine with print to get those displayed without the surrounding ' quotes.

sage: a = 1/2^70
sage: aa = '%.72f' % a
sage: print(aa)
0.000000000000000000000847032947254300339068322500679641962051391601562500
sage: ab = '{:.72f}'.format(float(a))
sage: print(ab)
0.000000000000000000000847032947254300339068322500679641962051391601562500


more