On Thu, 01 Apr 2010 19:55:27 -0400, David Robinow wrote:

>>> superpollo wrote:
>>> > how much is one half times one half?
[...]
>  Well, my python says:
> 
> $ python -c "print 1/2 * 1/2"
> 0
> 
>  But that's not what I learned in grade school.
> (Maybe I should upgrade to 3.1?)

Python 2.x defaults to integer division, a design error which has been 
rectified in 3.x.

One can do any of these:

[st...@sylar ~]$ python3.1 -c "print(1/2 * 1/2)"
0.25
[st...@sylar ~]$ python2.6 -c "from __future__ import division; print 1/2 
* 1/2"
0.25
[st...@sylar ~]$ python2.6 -Q new -c "print 1/2 * 1/2"
0.25
[st...@sylar ~]$ python2.6 -c "print 0.5 * 0.5"
0.25


and probably many others as well.



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to