2

I am trying to print scientific numbers with all the significant digits after the decimal point. `

Python's scientific notation prints with one digit before the dot like 1.2345678E+03,

'%E' % Decimal('1234.5678')
'1.2345678E+03'

but I want to print 0.12345E+04 instead.

Edit: A more generalized approach to have arbitrary number of digits before and after the dot would be more helpful. Like being able to print 123.456E+01 or 1234.56E-01 etc.

fzn
  • 514
  • 3
  • 10
  • `1.2345678E+03 / 10E+03` – RomanPerekhrest Jun 16 '17 at 06:58
  • 2
    I'm not aware of anything built in, so you'll probably have to write your own code to do this. – user94559 Jun 16 '17 at 07:03
  • @RomanPerekhrest This gives a decimal number. Converting it back to scientific notation would again move one significant digit before the dot. A more generalized approach to have arbitrary number of digits before and after the dot would be more helpful. e.g. `123.456E+01` or `1234.56E-01` etc. – fzn Jun 16 '17 at 07:04
  • 4
    Possible duplicate of [python scientific notation with forced leading zero](https://stackoverflow.com/questions/21266850/python-scientific-notation-with-forced-leading-zero) – vishes_shell Jun 16 '17 at 07:08
  • @vishes_shell any suggestions about the edit? – fzn Jun 16 '17 at 07:34
  • 1
    Check the link, of @vishes_shell. As what you want is not the standard scientific representation, there is no built in way to format the way you want it. – Kraay89 Jun 16 '17 at 07:42

0 Answers0