The printer has an option to do this. Use sstr() and set the full_prec flag.

Aaron Meurer

On Tue, Jul 14, 2015 at 2:53 PM, Paul Royik <[email protected]> wrote:

> str(a).rstrip('0') trick won't won't work with complex numbers, like
> 0.3000000000000+0.50000000000i
>
> On Monday, July 13, 2015 at 7:08:27 PM UTC+3, Vinzent Steinberg wrote:
>>
>> 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/cbd44009-2081-4bfb-9c20-330afbcb15ad%40googlegroups.com
> <https://groups.google.com/d/msgid/sympy/cbd44009-2081-4bfb-9c20-330afbcb15ad%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAKgW%3D6%2BiwtzE%2Bnfcm%3DW4x%3D5sFvG%2BoCdx0eD7DEt%2BGRn6S6y%2BJg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to