hi I want python to return 0.5 if I write 1/2 (and not 1.0/2.0). how do I make python to return the floating point? (I tried using getcontext().prec form decimal module)
thanks
Ariel
hi I want python to return 0.5 if I write 1/2 (and not 1.0/2.0). how do I make python to return the floating point? (I tried using getcontext().prec form decimal module)
thanks
Ariel
Python 3.x works the way you want by default.
Python 2.2 and greater support from __future__ import division, which makes / return floating point. There is also the // operator that still performs integer division when needed.
Also see PEP238 - Changing the Division Operator.