On Sunday, July 12, 2015 at 6:18:26 PM UTC+2, Paul Royik wrote:
>
> Is it possible to set for float precision of 50, but to cut trailing zeros
> for finite decimals?
> a=Float('0.5',prec=50)
> print a/7
> Output: 0.071428571428571428571428571428571428571428571428571
>
>
> a=Float('0.5',prec=50)
> print a
> Output: 0.50000000000000000000000000000000000000000000000000 (but I want a)
>
> For latex correct output is 0.5
> But how to print 0.5 instead of 0.5 with many trailing zeros?
>
In floating point representation, there is no difference between finite and
non-finite decimals, so they are printed the same.
If you want to remove trailing zeros, convert it to a string and strip the
zeros:
a_without_zeros = str(a).rstrip('0')
Vinzent
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/fd15295f-20af-4172-98c5-9d11c436d1b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.