[BangPypers] strange behavior

Nanolets nanolets srini at nanolets.in
Fri Jul 11 08:25:25 CEST 2008


http://www.python.org/doc/current/lib/typesnumeric.html for Documentation

Specifically

For (plain or long) integer division, the result is an integer. The result
is always rounded towards minus infinity: 1/2 is 0, (-1)/2 is -1, 1/(-2) is
-1, and (-1)/(-2) is 0. Note that the result is a long integer if either
operand is a long integer, regardless of the numeric value.

On Thu, Jul 10, 2008 at 10:24 AM, Gopal Ghosh <gopalmessages at gmail.com>
wrote:

> Dear sir / madam
> I am a new user of python and this is my first mail to local user group of
> python. I came across a strange behavior pf python n unable to explain it
>
>
> *********************
> >>> 7/3
> 2
> >>> 7/-3
> -3
> >>> 3/7
> 0
> >>> # again reapting the questions with one more decimal place
> >>> 7.0/3
> 2.3333333333333335
> >>> 7.0/-3
> -2.3333333333333335
> >>> 3.0/7
> 0.42857142857142855
> >>> # why it is not showing the exact values in the previous cases
> >>>
> ********************************
> ur help will strengthen my love for python
> Thanks
> Regards
>
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/bangpypers/attachments/20080711/4addb91e/attachment.htm>


More information about the BangPypers mailing list