can you help guys?
brokolists
coreyahmet at gmail.com
Fri Apr 24 10:29:37 CEST 2015
24 Nisan 2015 Cuma 02:20:12 UTC+3 tarihinde Steven D'Aprano yazdı:
> On Fri, 24 Apr 2015 01:51 am, brokolists 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)
>
>
> Are you sure? Can you give an example? This works for me:
>
> py> s = input("Enter a number: ")
> Enter a number: 0.123456789012345
> py> len(s) - 2 # Number of digits
> 15
> py> x = float(s)
> py> print(x)
> 0.123456789012345
>
> Maybe you shouldn't be using floats:
>
> py> n = int(input("Enter a number: "))
> Enter a number: 123456789012345678901234567890
> py> print(n)
> 123456789012345678901234567890
> py> print(n+1)
> 123456789012345678901234567891
>
>
> Integers will not use scientific "e" notation, but floats will. But that is
> only the *display* format:
>
> py> x = float(input("Enter a number in Sci format: "))
> Enter a number in Sci format: 1.234e10
> py> print(x)
> 12340000000.0
> py> print("%f" % x)
> 12340000000.000000
> py> print("%g" % x)
> 1.234e+10
>
> Notice that displaying the float with %f and %g format codes look different,
> but are the same number.
>
> You will need to explain more about what you are trying to do before we can
> give you good advise. Perhaps if you show us some examples?
>
>
>
>
> --
> Steven
i fixed the "e" problem by using digits
getcontext().prec=20
it works fine but in my algoritm it was checking the answers by their lenght so this created a new problem by giving all the answers with 20 digits. I might fix this but i have searched for 4 hours just how to get rid of 'e' . i think there must be a easier way to do this.
More information about the Python-list
mailing list