Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   division bug? (http://www.velocityreviews.com/forums/t331890-division-bug.html)

 Milan 06-09-2004 02:55 PM

division bug?

a program:

a=10
b=5
print a/b

and its result: 0. If you run the program, you see always a sero (0),
but 10/5 is 2. Who can help me?

 Russell Blau 06-09-2004 03:03 PM

Re: division bug?

"Milan" <milanmor@yahoo.com> wrote in message
> a program:
>
> a=10
> b=5
> print a/b
>
> and its result: 0. If you run the program, you see always a sero (0),
> but 10/5 is 2. Who can help me?

Python 2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC v.1200 32 bit (Intel)] on
win32

>>> a = 10
>>> b = 2
>>> print a/b

5

What version are *you* running?

--
I don't actually read my hotmail account, but you can replace hotmail with
excite if you really want to reach me.

 Grant Edwards 06-09-2004 03:04 PM

Re: division bug?

On 2004-06-09, Milan <milanmor@yahoo.com> wrote:
> a program:
>
> a=10
> b=5
> print a/b
>
> and its result: 0. If you run the program, you see always a zero (0),

> but 10/5 is 2. Who can help me?

Perhaps you can. :)

>>> 5/10

0
>>> 5.0/10.0

0.5
>>> 5//10

0
>>> 5.0//10.0

0.0

--
Grant Edwards grante Yow! Hold the MAYO & pass
at the COSMIC AWARENESS...
visi.com

 Duncan Booth 06-09-2004 03:06 PM

Re: division bug?

milanmor@yahoo.com (Milan) wrote in

> a program:
>
> a=10
> b=5
> print a/b
>
> and its result: 0. If you run the program, you see always a sero (0),
> but 10/5 is 2. Who can help me?
>
>

I don't know who can help you, but this is a Python newsgroup and if you
try your program in Python it prints 2, so perhaps you are using some other
language:

>>> a=10
>>> b=5
>>> print a/b

2

If you are using Python, try cutting and pasting the exact code and the
problem you think you see, and we can try to help you from there.

 Skip Montanaro 06-09-2004 03:16 PM

Re: division bug?

Milan> a program:
Milan> a=10
Milan> b=5
Milan> print a/b

Milan> and its result: 0. If you run the program, you see always a sero
Milan> (0), but 10/5 is 2. Who can help me?

Works for me:

% python
Python 2.4a0 (#25, May 22 2004, 15:16:21)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1493)] on darwin
>>> a=10
>>> b=5
>>> print a/b

2

I think you'll need to give more details (platform, version, actual
interpreter output, etc) to get any more useful help.

Skip

 Steven Rumbalski 06-09-2004 04:51 PM

Re: division bug?

Milan wrote:

> a program:
>
> a=10
> b=5
> print a/b
>
> and its result: 0. If you run the program, you see always a sero (0),
> but 10/5 is 2. Who can help me?

You probably have reversed a & b in your program somewhere. Zero is the
correct result with the numbers reversed.

>>> a = 10
>>> b = 5
>>> print "a/b = %s\nb/a = %s" % (a/b, b/a)

a/b = 2
b/a = 0

If you import division from __future__ my guess is that you will see the
result of 0.5. If this is the case you have mixed a & b up somewhere.

>>> from __future__ import division
>>> print "a/b = %s\nb/a = %s" % (a/b, b/a)

a/b = 2.0
b/a = 0.5

--
Steven Rumbalski
news|at|rumbalski|dot|com

 All times are GMT. The time now is 10:53 AM.