Re: 1/2 evaluates to 0

2011-10-14 Thread 88888 dihedral
How about fractions to be computed in hundreds or even thousands of digits in precision? OK, just write programs to compute PI and the Euler number in hundreds or even thousands of digits to test various kind of programming languages. This is a sophomore school home work for gifted kid

Re: 1/2 evaluates to 0

2011-10-13 Thread Laurent Claessens
You should get in touch with the Sage developers. In the Sage FAQ they say that "until SciPy is ported to run with Python 3.x and Cython supports Python 3.x, Sage will continue to use Python 2.x." ``scipy.weave``." So according to the Sage FAQ there is no reason why Sage shouldn't support Pyt

Re: 1/2 evaluates to 0

2011-10-13 Thread SigmundV
On Oct 13, 10:04 am, Laurent Claessens wrote: > Thanks all for your ansers. I'll import division from __future__ > Most of what I'm using in Python is with Sage[1]. Thus I'm not about to > step to 3.x :( You should get in touch with the Sage developers. In the Sage FAQ they say that "until SciPy

Re: 1/2 evaluates to 0

2011-10-13 Thread Laurent Claessens
Wohaw. This means that this behavior is going to be default in a foreseeable future ? It's the default in 3.x. I can't imagine it ever being the default in 2.x. 2.7 is now in "bug-fix only" mode, so no new features, and there won't be a 2.8, so true division will never be the default in

Re: 1/2 evaluates to 0

2011-10-12 Thread Steven D'Aprano
Nobody wrote: > On Wed, 12 Oct 2011 13:28:35 +0200, Laurent wrote: > >> from __future__ import division >> 1/2 >>> 0.5 >>> >> >> Wohaw. This means that this behavior is going to be default in a >> foreseeable future ? > > It's the default in 3.x. I can't imagine it ever being the defa

Re: 1/2 evaluates to 0

2011-10-12 Thread Noah Hall
On Wed, Oct 12, 2011 at 12:28 PM, Laurent wrote: > >> Include from __future__ import division on the top of your file >> >  from __future__ import division >  1/2 >> >> 0.5 >> > > Wohaw. This means that this behavior is going to be default in a foreseeable > future ? Never in Python 2.x,

Re: 1/2 evaluates to 0

2011-10-12 Thread Nobody
On Wed, 12 Oct 2011 13:28:35 +0200, Laurent wrote: > from __future__ import division > 1/2 >> 0.5 >> > > Wohaw. This means that this behavior is going to be default in a > foreseeable future ? It's the default in 3.x. I can't imagine it ever being the default in 2.x. -- http://mail.

Re: 1/2 evaluates to 0

2011-10-12 Thread Laurent
Include from __future__ import division on the top of your file from __future__ import division 1/2 0.5 Wohaw. This means that this behavior is going to be default in a foreseeable future ? Thanks Laurent -- http://mail.python.org/mailman/listinfo/python-list

Re: 1/2 evaluates to 0

2011-10-12 Thread Peter Otten
Laurent Claessens wrote: > This is well known : > > >>> 1/2 > 0 > > This is because the division is an "integer division". > > My question is : how can I evaluate 1/2 to 0.5 ? Is there some non > integer division operator ? > Up to now I workarounded writing float(1)/2. Is there an other way ?

Re: 1/2 evaluates to 0

2011-10-12 Thread Paul Rudin
Laurent Claessens writes: > Hi all > > > This is well known : > 1/2 > 0 > > This is because the division is an "integer division". > > My question is : how can I evaluate 1/2 to 0.5 ? Is there some non > integer division operator ? > Up to now I workarounded writing float(1)/2. Is there an o

Re: 1/2 evaluates to 0

2011-10-12 Thread Aage Andersen
"Laurent Claessens" skrev i en meddelelse news:j73p9s$baa$1...@news.univ-fcomte.fr... > Hi all > > > This is well known : > > >>> 1/2 > 0 > > This is because the division is an "integer division". > > My question is : how can I evaluate 1/2 to 0.5 ? Is there some non integer > division operator

Re: 1/2 evaluates to 0

2011-10-12 Thread Chris Angelico
On Wed, Oct 12, 2011 at 9:14 PM, Laurent Claessens wrote: > Hi all > > This is well known : > 1/2 > 0 Only in Python 2. > This is because the division is an "integer division". > > My question is : how can I evaluate 1/2 to 0.5 ? Is there some non integer > division operator ? 1.0/2 is flo

Re: 1/2 evaluates to 0

2011-10-12 Thread Noah Hall
On Wed, Oct 12, 2011 at 11:14 AM, Laurent Claessens wrote: > This is well known : > 1/2 > 0 > > This is because the division is an "integer division". > > My question is : how can I evaluate 1/2 to 0.5 ? Is there some non integer Include from __future__ import division on the top of your fil

Re: 1/2 evaluates to 0

2011-10-12 Thread Jean-Michel Pichavant
Laurent Claessens wrote: Hi all This is well known : >>> 1/2 0 This is because the division is an "integer division". My question is : how can I evaluate 1/2 to 0.5 ? Is there some non integer division operator ? Up to now I workarounded writing float(1)/2. Is there an other way ? My Zen