[Ilugc] Need Help : Setting Floating Precision Point as 2 in Python

  • From: arulalant@xxxxxxxxx (Arulalan T)
  • Date: Tue Aug 24 17:32:19 2010

2010/8/24 Roshan George <roshan@xxxxxxxxx>

On Tue, 2010-08-24 at 16:57 +0530, Arulalan T wrote:
Yes, we can do this multiply by 100 way.
By this way I can handle 80 and 23 as two separate integers.
But when I want make it as float
80+0.23
 80.230000000000004

again it will be come same floating value.
so I cant use this way.

Well, I meant something like using 8000 and 23 instead of 80 and 0.23.
Then when the time comes to print your number you can just do something
like:

       a = str(8000+23)
       b = a[:-2] + '.' + a[-2:]


Thanks a lot. I forget to mention here. I dont want the result float value
in string.

I need only the float values with 2 precision. That to without rounding the
result.

Any idea?






Your output will be the nice 80.23 that you always wanted. Unless you're
doing some division that requires you to hold on to the third place or
lower, why use floats when integers will do the job?

--
Roshan George

_______________________________________________
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc




-- 
Regards,
Arulalan.T

Kanchi Linux User Group Rocks !
http://kanchilug.wordpress.com

My Experiments In Linux are here
http://tuxcoder.wordpress.com

Other related posts: