ROUNDING???

7stud bbxx789_05ss at yahoo.com
Tue Feb 19 04:05:47 CET 2008


On Feb 18, 7:57 pm, katie smith <iceboy... at yahoo.com> wrote:
> in python im doing the problem 255/494
>
> it keeps giving me 0 instead of .51....
> what am i doing wrong?
>
> please help me I have been looking for hours
>
>       ___________________________________________________________________________ _________
> Never miss a thing.  Make Yahoo your home page.http://www.yahoo.com/r/hs

An integer divided by an integer produces an integer.  In computer
programming, that's called 'integer arithmetic', and any fractional
part of the result is chopped off(not rounded).  If your arithmetic
involves at least one float, then you will get a float as an asnwer:


print 255/494
print 255.0/494
print (255 * 1.0)/494

--output:--
0
0.516194331984
0.516194331984



More information about the Python-list mailing list