Precedence of %

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Precedence of %
Дата
Msg-id 200506040356.j543uki09397@candle.pha.pa.us
обсуждение исходный текст
Ответы Re: Precedence of %  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
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,
Pennsylvania19073
 


В списке pgsql-hackers по дате отправления:

Предыдущее
От: "John Hansen"
Дата:
Сообщение: Re: executing OS programs from pg
Следующее
От: Neil Conway
Дата:
Сообщение: Re: need help