>>> ndec = lambda x: 0 if '.' not in str(x) else len(str(x).split('.')[1].split('e')[0]) >>> (1, 1.0, 1.23, 1.234e-5, 3e5, 3e33) (1, 1.0, 1.23, 1.234e-05, 300000.0, 3e+33) >>> [ndec(i) for i in _] [0, 1, 2, 3, 1, 0]
(Note that this is not the same thing as the number of significant digits. And if you don't want to count trailing 0s then change `[0]` to `[0].rstrip('0')`) /c On Friday, April 16, 2021 at 5:23:17 AM UTC-5 distan...@gmail.com wrote: > How do I make sure that str() doesn't return exponential notation? > > On Friday, April 16, 2021 at 11:43:22 AM UTC+3 asme...@gmail.com wrote: > >> In that case, I think the simplest option would be to parse >> str(float). Some split() and strip() operations should get you want >> you want, or just use a regex. >> >> Aaron Meurer >> >> On Thu, Apr 15, 2021 at 11:56 PM Paul Royik <distan...@gmail.com> wrote: >> > >> > One digit. Ignore scientific notation. >> > >> > On Friday, April 16, 2021 at 1:23:53 AM UTC+3 asme...@gmail.com wrote: >> >> >> >> How would you count small numbers like 1.1e-30. Is that 1 digit or 31 >> >> digits after the decimal? >> >> >> >> Aaron Meurer >> >> >> >> On Thu, Apr 15, 2021 at 2:31 PM Paul Royik <distan...@gmail.com> >> wrote: >> >> > >> >> > Rational(1,2).evalf(), how do I get 1 here (since 0.5 has 1 digit >> after the dot)? >> >> > >> >> > -- >> >> > 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/73ee2ab4-7b12-4938-a1ed-079b3a33fc14n%40googlegroups.com >> . >> > >> > -- >> > 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/643b8e44-91f1-475f-87ed-f444d584bbaen%40googlegroups.com >> . >> > -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/4fb96f84-4e74-4293-ba64-337b42ec7633n%40googlegroups.com.