Print floats without an exponent

39 views
Skip to first unread message

Paul Royik

unread,
Mar 24, 2021, 7:53:58 AM3/24/21
to sympy
How can I print Float(0.00005) as it is without exponent?

Chris Smith

unread,
Mar 24, 2021, 12:07:24 PM3/24/21
to sympy
Search online for "python print format number"

    >>> '{:f}'.format(5e-5)
    0.000050

Aaron Meurer

unread,
Mar 24, 2021, 2:59:22 PM3/24/21
to sympy
You can use the min and max flags to the printer function (like sstr()
or pprint() or latex()). They set the minimum and maximum values to
print as fixed point. You can use min=-float('inf'), max=float('inf')
to always print every float as fixed point. These flags don't seem to
be documented, but if you look at the documentation for
mpmath.libmp.to_str, they are passed to the min_fixed and max_fixed
flags of that function.

Aaron Meurer
> --
> 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 sympy+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/b2c340b5-a689-466d-abfb-83a6381d0379n%40googlegroups.com.

Paul Royik

unread,
Mar 24, 2021, 3:04:51 PM3/24/21
to sympy
Thank you.

Paul Royik

unread,
Mar 25, 2021, 12:58:11 PM3/25/21
to sympy

What should I set if I want to show numbers n, such that abs(n)<10**-11 with exponent?
I can't set negative infinity here.
Reply all
Reply to author
Forward
0 new messages