[#1026] Is this a bug? — Dave Thomas <Dave@...>

18 messages 2000/01/03

[#1084] Infinite loop — Dave Thomas <Dave@...>

17 messages 2000/01/11

[#1104] The value of while... — Dave Thomas <Dave@...>

24 messages 2000/01/11

[ruby-talk:01162] Possible bug in ruby-man-1.4

From: Dave Thomas <Dave@...>
Date: 2000-01-22 03:03:27 UTC
List: ruby-talk #1162
In the section on Fixnum, the documentation for 'remainder' says:


            Returns remainder of the numbers. In case either number is
            negative, the evaluated value differs from that of the
            operator %.

                  13 % 4 => 1
                  13 % -4 => -3
                  -13 % 4 => 3
                  -13 % -4 => -1
                  13.remainder(4) => 1
                  13.remainder(-4) => 1
                  -13.remainder(4) => -1
                  -13.remainder(-4) => -1 

I'm probably wrong (again), but doesn't

    -13.remainder(-4)

parse as

    -(13.remainder(4))

not

    (-13).remainder(4)


This precedence stuff is non-trivial!

Dave

In This Thread

Prev Next