Hi Arulalan,

> 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
>

You might want to convert them to Decimal type. Look up the
following URL (Python documentation) for more information:
      http://docs.python.org/library/decimal.html

If all you want to do is "print" the value upto 2 decimal points, then
a print with format specifier should do the trick. The following URL
(Stack Overflow) has this question answered:

http://stackoverflow.com/questions/455612/python-limiting-floats-to-two-decimal-points

Cheers,
Chandrashekar.

-- 
Chandrashekar Babu.,
http://www.chandrashekar.info/
_______________________________________________
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc

Reply via email to