Does anyone understand why the precedence of % is strange:
        
        test=> select -25 % -10;
         ?column?
        ----------
              -35
        (1 row)
        
        test=> select -25 % (-10);
         ?column?
        ----------
               -5
        (1 row)

Is it treating the first as -25 - 10?  Why?  Why are parens necessary to
get the right answer?  I see this in gram.y:

        %left       '+' '-'
        %left       '*' '/' '%'

Look at this:

        test=> select -25 + -10;
         ?column?
        ----------
              -35
        (1 row)
        
        test=> select -25 * -10;
         ?column?
        ----------
              250
        (1 row)
        
        test=> select -25 / -10;
         ?column?
        ----------
                2
        (1 row)
        
        test=> select -25 % -10;
         ?column?
        ----------
              -35
        (1 row)

Only the '%' case looks wrong.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Reply via email to