ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 04 Sep 2011 14:47:40 +0200number formattinghttps://ask.sagemath.org/question/8306/number-formatting/Is it possible to display all numbers >= 10^4 (or <= 10^-4) in scientific notation?
Regards
Georg Sun, 04 Sep 2011 08:11:09 +0200https://ask.sagemath.org/question/8306/number-formatting/Answer by niles for <p>Is it possible to display all numbers >= 10^4 (or <= 10^-4) in scientific notation?</p>
<p>Regards </p>
<p>Georg </p>
https://ask.sagemath.org/question/8306/number-formatting/?answer=12623#post-id-12623You could use python's [string formatting](http://docs.python.org/library/string.html) to print numbers in scientific notation:
sage: n = 215.685
sage: print "my number is %e"%n
my number is 2.156850e+02
sage: print "my number is %E"%n
my number is 2.156850E+02
Is that the kind of thing you're looking for?Sun, 04 Sep 2011 10:46:57 +0200https://ask.sagemath.org/question/8306/number-formatting/?answer=12623#post-id-12623Comment by niles for <p>You could use python's <a href="http://docs.python.org/library/string.html">string formatting</a> to print numbers in scientific notation:</p>
<pre><code>sage: n = 215.685
sage: print "my number is %e"%n
my number is 2.156850e+02
sage: print "my number is %E"%n
my number is 2.156850E+02
</code></pre>
<p>Is that the kind of thing you're looking for?</p>
https://ask.sagemath.org/question/8306/number-formatting/?comment=21280#post-id-21280oh; yes, that ticket might help, but I don't know if conditional formatting is something they're thinking about. If you want to get involved, you could contribute there too :)Sun, 04 Sep 2011 14:47:40 +0200https://ask.sagemath.org/question/8306/number-formatting/?comment=21280#post-id-21280Comment by Georg Damm for <p>You could use python's <a href="http://docs.python.org/library/string.html">string formatting</a> to print numbers in scientific notation:</p>
<pre><code>sage: n = 215.685
sage: print "my number is %e"%n
my number is 2.156850e+02
sage: print "my number is %E"%n
my number is 2.156850E+02
</code></pre>
<p>Is that the kind of thing you're looking for?</p>
https://ask.sagemath.org/question/8306/number-formatting/?comment=21281#post-id-21281Maybe the ticket
http://trac.sagemath.org/sage_trac/ticket/7682
would resolve the issue?Sun, 04 Sep 2011 11:20:24 +0200https://ask.sagemath.org/question/8306/number-formatting/?comment=21281#post-id-21281Comment by Georg Damm for <p>You could use python's <a href="http://docs.python.org/library/string.html">string formatting</a> to print numbers in scientific notation:</p>
<pre><code>sage: n = 215.685
sage: print "my number is %e"%n
my number is 2.156850e+02
sage: print "my number is %E"%n
my number is 2.156850E+02
</code></pre>
<p>Is that the kind of thing you're looking for?</p>
https://ask.sagemath.org/question/8306/number-formatting/?comment=21282#post-id-21282No. I want something like that: sage: x=1.2345678 -> sage: x -> 1.2345678 sage: x = 0.00003 -> sage: x -> 3E-05. Sage print a number x in scientific notation if x>=10^7 or 0 < x <= 10^-7. Sun, 04 Sep 2011 11:03:04 +0200https://ask.sagemath.org/question/8306/number-formatting/?comment=21282#post-id-21282