On Tuesday, 6 September 2011 00:51:54 UTC+10, Joep wrote:
>
> > rather than:
> >     y = y & 63 -- or equivalent constant
>
> Check with y=180 (not sure if it is an intended difference though).
>
Is that a trick question? I don't think they are different.

I got all unit-testy, the following Ruby script (which runs all the Jal 
if/thens unmodified*) says they produce the same value for all 8-bit 
numbers:

#! /usr/bin/ruby


SCREEN_MAX_Y = 63

SCREEN_ROWS = 64


def three_ifs_way(y)

    if y > 191 then 

         y = y - 192 

    elsif y > 127 then 

         y = y - 128 

    elsif y > SCREEN_MAX_Y then 

         y = y - SCREEN_ROWS 

    end

    return y

end


def one_AND_way(y)

    return y & 63

end


#### main loop


return_value = 0


for i in 0..255

    if three_ifs_way(i) != one_AND_way(i) then

        puts "Bad! Methods differ for value #{i}"

        return_value += 1

    end

end
exit return_value 


* had to change "end if" to just "end" 

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/jallib/-/SUe3qf3xYfAJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en.

Reply via email to