Johan Geldenhuys wrote: > Hi all, > > In my script I want to convert 14105 bytes to kilobytes and and this is > what I do: > >> >> s = 14105 >> >> print '%0.2f' % (s/1024) > 13.00 > > This not correct and I don't know why. The answer is 13.77. > > Any pointers please that would help my in the right direction?
As well as the solutions Geofram has given, you can change the behaviour of addition like this: In [2]: from __future__ import division In [3]: 14105/1024 Out[3]: 13.7744140625 Then the old-style integer division is done with //: In [4]: 14105//1024 Out[4]: 13 More info here: http://www.python.org/doc/2.2.3/whatsnew/node7.html Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor