can you help guys?

Ian Kelly ian.g.kelly at gmail.com
Thu Apr 23 20:44:22 CEST 2015


On Thu, Apr 23, 2015 at 9:51 AM, brokolists <coreyahmet at gmail.com> wrote:
> my problem is i m working with very long float numbers and i use
> numberx =float(( input( 'enter the number\n ')))
> after i use this command when i enter something more than 10 or 11 digits it uses like 1e+10 or something like that
> but i have to calculate it without scientific 'e' type. what can i do to solve this?
> (sorry for my bad english)

That's just how the number is formatted for output by default. It has
nothing to do with how the number is handled in memory. You can
prevent it from outputting scientific notation using the 'f' format
specifier. Pick whichever example best suits your use.

>>> num = 12345678901234567890.
>>> print(num)
1.2345678901234567e+19
>>> print('%f' % num)  # Using percent formatting
12345678901234567168.000000
>>> print('{:f}'.format(num))  # Using the str.format method
12345678901234567168.000000
>>> print(format(num, 'f'))  # Using the format builtin
12345678901234567168.000000

Now, if you're working with very long floats then you're probably also
running into precision issues, as you can see in the examples above.
If the precision is important to you, then you may want to consider
using decimals instead of floats.



More information about the Python-list mailing list