division bug?

M

Milan

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?
 
R

Russell Blau

Milan said:
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
Type "copyright", "credits" or "license()" for more information.
5

What version are *you* running?
 
D

Duncan Booth

(e-mail address removed) (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:
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.
 
S

Skip Montanaro

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
Type "help", "copyright", "credits" or "license" for more information. 2

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

Skip
 
S

Steven Rumbalski

Milan said:
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/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.
a/b = 2.0
b/a = 0.5
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top