Number precision

Markus Schaber markus at schabi.de
Fri Aug 10 17:53:37 EDT 2001


Hi,

Buzz B. <kraydl at hotmail.com> schrub:

> Excuse the rookie question:
> 
> x=50
> x/100 results in 0 instead of .5
> 
> Now I can do:
> y = float(x)/100  to get the correct answer
> 
> Is there a way to predefine x as a floating?

No, as variables are not typed.

You could either do one of the two solutions already showed, or use

y = x/100.0

or use a x = float(x) before the division.
 

-- 
1) Customers cause problems.
2) Marketing is trying to create more customers.
Therefore:
3) Marketing is evil.  (Grand Edwards in comp.lang.python)



More information about the Python-list mailing list