Hi Arun, Check out this >>> a=79.73 >>> b=0.5 >>> c = '%.2f' %(a+b) >>> c '80.23'
Hope this help. With Regards Vijay --- On Tue, 24/8/10, Arulalan T <arulal...@gmail.com> wrote: From: Arulalan T <arulal...@gmail.com> Subject: [BangPypers] Need Help : Setting Floating Precision Point as 2 in Python To: "Bangalore Python Users Group - India" <bangpypers@python.org> Date: Tuesday, 24 August, 2010, 4:05 PM Dear All, I need one help. In python, I need to set the floating point precision as 2. I am getting the following output in python while adding two float nos. >>>a=79.73 >>>b=0.5 >>> a+b 80.230000000000004 I need exactly 2 precision point in this float value. i.e. 80.23 Even though I tried in round method, its not satisfied me. Because >>> a = round(3.7138464897123424324355124355,2) >>> a 3.71 >>> a = round(3.7238464897123424324355124355,2) >>> a 3.7200000000000002 Can you understand the difference. Depends upon the value, it will round. I no need ceil and floor options. Because it may change the original values. I need just 2 precision point in the float value. I am getting two numbers dynamically. So I can not say exactly, what kind of floating numbers I am going to use. What I have to do ? Any suggestions ? Thanks in advance. -- Regards, Arulalan.T Kanchi Linux User Group Rocks ! http://kanchilug.wordpress.com My Experiments In Linux are here http://tuxcoder.wordpress.com _______________________________________________ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers _______________________________________________ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers