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

2010-08-24 Thread Arulalan T
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.234 I need exactly 2 precision point in this float value. i.e. 80.23 Even though I tried in

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

2010-08-24 Thread Pradip Caulagi
On Tue, Aug 24, 2010 at 4:05 PM, Arulalan T wrote: > > 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 Multiply by 100. Add as integers. Divide by 100. _

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

2010-08-24 Thread kausikram krishnasayee
> I am getting the following output in python while adding two float nos. > a=79.73 > b=0.5 the reason for which is: http://docs.python.org/tutorial/floatingpoint.html -- Kausikram Krishnasayee Company: http://silverstripesoftware.com | Webpage: kausikram.in | Blog: blog.kausikram.in | Twitter: h

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

2010-08-24 Thread vijay
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 wrote: From: Arulalan T Subject: [BangPypers] Need Help : Setting Floating Precision Point as 2 in Python To: "Bangalore Python Users Grou

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

2010-08-24 Thread Arulalan T
Hi, 2010/8/24 vijay > Hi Arun, >Check out this > >>> a=79.73 > >>> b=0.5 > >>> c = '%.2f' %(a+b) > >>> c > '80.23' > It is string. >>> float(c) 80.234 Again same problem getting . :( I need it as float only. > > Hope this help. > > With Regards > Vijay > > > --- On Tue, 24/8/

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

2010-08-24 Thread Arulalan T
2010/8/24 Pradip Caulagi > On Tue, Aug 24, 2010 at 4:05 PM, Arulalan T wrote: > > > > 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 > > Multiply by 100. > Add as integers.

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

2010-08-24 Thread Noufal Ibrahim
(I posted this to ChennaiPy but this list is wider so I'm reposting it). Arulalan T writes: > 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. Often, you *need* to only d

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

2010-08-24 Thread Arulalan T
2010/8/24 Noufal Ibrahim > > (I posted this to ChennaiPy but this list is wider so I'm reposting > it). > > Arulalan T writes: > > > 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 ad

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

2010-08-24 Thread Noufal Ibrahim
Arulalan T writes: [...] >> Often, you *need* to only display the result of your calculations with n >> decimal places. Is yours such a situation? If so, forget the number of >> decimal points during the computation and when printing format it as >> appropriate ("%.2f"). >> >> > I am not just pr

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

2010-08-24 Thread Arulalan T
2010/8/24 Noufal Ibrahim > Arulalan T writes: > > [...] > > >> Often, you *need* to only display the result of your calculations with n > >> decimal places. Is yours such a situation? If so, forget the number of > >> decimal points during the computation and when printing format it as > >> appro

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

2010-08-24 Thread Roshan Mathews
On Tue, Aug 24, 2010 at 17:52, Arulalan T wrote: > This gives the what I need. > But I can not use this Decimal data type. > > In CDAT vcs module supports only the 'float data' type to represent the > latitude & logitude in map. > > so I need float value in 2 precision without changing the value.

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

2010-08-24 Thread Arulalan T
2010/8/24 Roshan Mathews > On Tue, Aug 24, 2010 at 17:52, Arulalan T wrote: > > This gives the what I need. > > But I can not use this Decimal data type. > > > > In CDAT vcs module supports only the 'float data' type to represent the > > latitude & logitude in map. > > > > so I need float value

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

2010-08-24 Thread Noufal Ibrahim
Arulalan T writes: [...] > This gives the what I need. > But I can not use this Decimal data type. > > In CDAT vcs module supports only the 'float data' type to represent the > latitude & logitude in map. > > so I need float value in 2 precision without changing the value. Not in > string. Not

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

2010-08-24 Thread Noufal Ibrahim
Arulalan T writes: [...] > In CDAT[1] vcs module supports only the 'float data' type to represent > the latitude & logitude in World map. So I cant use Decimal or a > string an integer. Only float. [...] I think that's a bug. The module should rely on duck typing rather than on concrete typ

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

2010-08-24 Thread Arulalan T
2010/8/24 Noufal Ibrahim : > Arulalan T writes: > > [...] > >> In CDAT[1] vcs module supports only the 'float data' type to represent >> the latitude & logitude in World map.  So I cant use Decimal or a >> string an integer. Only float. > > [...] > > I think that's a bug. > > The module should rel

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

2010-08-24 Thread renuka prasad
On Tue, Aug 24, 2010 at 7:29 PM, Arulalan T wrote: > 2010/8/24 Noufal Ibrahim : > > Arulalan T writes: > > > > [...] > > > >> In CDAT[1] vcs module supports only the 'float data' type to represent > >> the latitude & logitude in World map. So I cant use Decimal or a > >> string an integer. Only

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

2010-08-24 Thread Noufal Ibrahim
renuka prasad writes: [...] > what is the reason for the previous problem? can you elaborate a > bit.. What my understanding is that the typical code and value , that > is what we code is not the same as its value > > but would like to know more.. can you explain a bit? [...] It's generally

Re: [BangPypers] Clojure style multimethod functions in python

2010-08-24 Thread Baishampayan Ghose
>> Without making any change whatsoever to multi() and multi_method(), > the result of the following code : > > # Declare the existence of a multi method switcher > encounter = multi(lambda x,y : (x["Species"], y["Species"])) > > @multi_method(encounter, ("Bunny","Lion")) > def encounter(a1, a2): >