Thursday, 15 August 2013

floating point - python - Float values -



floating point - python - Float values -

i have function checking value list float:

= 0.00001 if (array [0] / array[1] < a) : #do # array list float64 type values , a's type float

will create problem in comparing? , when seek print value of a, shows 1e-05. why so?? new python. can explain me this.

will create problem in comparing?

if a[1] equal zero, or if a[0] / a[1] larger largest representable number, or smaller smallest representable number, may have problem.

the comparing well-defined , means pretty much think does.

when seek print value of a, shows 1e-05. why so?

that depends upon how seek print value of a. consider these ways of printing a:

in [1]: = 0.00001 in [2]: print 1e-05 in [3]: print '%f'%a 0.000010 in [4]: print '%e'%a 1.000000e-05 in [5]: print '%g'%a 1e-05

as can see, each way of printing a prints different text representation of a. 10, ten , 0xa represent same number (the number of fingers on hands), each of these results represent same number (the number when split 1 100,000 parts).

python floating-point

No comments:

Post a Comment