Ask Your Question

4uTeP's profile - activity

2017-05-10 01:57:38 +0100 received badge  Famous Question (source)
2016-03-31 09:45:51 +0100 received badge  Notable Question (source)
2016-03-31 09:45:51 +0100 received badge  Popular Question (source)
2014-02-17 13:42:25 +0100 marked best answer Cutting unnecessary zeroes in float numbers

You could just check that

type(x) == float

Or, instead of round, you could use python's string formatter.

"{:.5g}".format(x)

will format x using 5 digits of precision (including before and after the decimal separator), removing trailing zeroes and the decimal dot for integers. Not exactly equivalent to your code, but maybe it will be good enough for your use.

If you have a locale configured for French/Italian/whatever notation

"{:.5n}".format(x)

will automatically put a comma instead of a dot for you.

2014-02-17 13:42:25 +0100 received badge  Scholar (source)
2014-02-17 13:42:19 +0100 received badge  Supporter (source)
2014-02-17 13:30:28 +0100 answered a question Cutting unnecessary zeroes in float numbers

That was really dumb.

\begin{sagesilent}
  def numprint(x):
     x = round(x, ndigits=3)
     x = latex(x)
     x = str(x)
     x = x.replace('.', ',\!').replace('\\times','\, \ldotp')
     x = x.rstrip('0').rstrip(',\!') if ',\!' in x else x
     x = sage.misc.latex.LatexExpr(x)
     return x
\end{sagesilent}
\newcommand{\sagedot}[1]{\sagestr{numprint(RDF(#1))}}

Maybe this solution is dumb too, but it works :D

2014-02-17 12:49:59 +0100 received badge  Editor (source)
2014-02-17 12:49:32 +0100 asked a question Cutting unnecessary zeroes in float numbers

Hello. I have function, which shows a float number with comma instead of dot. But if i use this function on integer it shows float number. Here is the function

\begin{sagesilent}
  def numprint(x):
     x = round(x, ndigits=3)
     x = latex(x)
     x = str(x)
     x = x.replace('.', ',\!').replace('\\times','\, \ldotp')
     x = sage.misc.latex.LatexExpr(x)
     return x
\end{sage}
\newcommand{\sagedot}[1]{\sagestr{numprint(RDF(#1))}}

So, when i use \sagedot{3} it shows 3.0 instead of 3. Help me to improve it. Thanks and sorry for dumb english and question :D

2014-02-15 07:00:52 +0100 answered a question Using comma as a decimal mark with SageTeX
2014-02-14 10:19:35 +0100 received badge  Student (source)
2014-02-14 09:04:24 +0100 asked a question Using comma as a decimal mark with SageTeX

There are a lot of questions about how-to use comma instead of dot in standart LaTeX documents. But how i can do this in documents with SageTeX?

2014-02-14 09:03:24 +0100 asked a question Using comma as a decimal mark with SageTeX

There are a lot of questions about how-to use comma instead of dot in standart LaTeX documents. But how i can do this in documents with SageTeX?