[Tutor] Assistance with Psuedocode

Adam Bark adam.jtm30 at gmail.com
Thu Nov 18 01:55:28 CET 2010


On 18/11/10 00:49, Alan Gauld wrote:
>
> "Joe Ohmer" <ohmerj1 at mymail.nku.edu> wrote
>
>> The following code works well but I don't understand why
>> the mysteryEffect code block changes the picture.
>> Doesn’t 64*(r/64) just equal r?
>
> That dependfs on which version of Python you use.
> In  earlier versions '/' meant integer division so
>
> (1/64) * 64    => 0 * 64
> (120/64) * 64 => 1 * 64
> (128/64) * 64 => 2 * 64
> (130/64) * 64 => 2 * 64
>
> So only in the case of exact multiples of 64 does it do
> what you expect. However, if you have a recent version
> of Python (2.6? onwards) '/' means floating point division
> so now you get the result you expect (subject to rounding
> error)
>
> HTH,
>
Roughly what I was about to say. 2.6 doesn't do floating point division 
as standard. I think you can import that behaviour.


More information about the Tutor mailing list