Re: "Interesting" C behaviours
From: Malcolm (malcolm_at_55bank.freeserve.co.uk)
Date: 11/27/04
- Next message: Sean Hamilton: "Correct type for array indices"
- Previous message: sam1967_at_hetnet.nl: "Re: PORTING GMP PROGRAMS TO WINDOWS"
- In reply to: Rennie deGraaf: ""Interesting" C behaviours"
- Next in thread: Rennie deGraaf: "Re: "Interesting" C behaviours"
- Reply: Rennie deGraaf: "Re: "Interesting" C behaviours"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 27 Nov 2004 06:51:06 -0000
"Rennie deGraaf" <ca.ucalgary.cpsc@degraaf> wrote
> In the last few days, I have discovered two "interesting" behaviours of
> the C language, both of which are apparently correct. Could someone
> please explain the reasoning behind them?
>
> 1. The operators '^', '&', and '|' have lower precedance than '==',
> '!=', '>=", etc.
>
You'd have to ask K and R about this. The problem is that the language was
designed by two people in a back room somewhere, and once set, the
precedence rules are very difficult to change.
>
> 2. In C99, the expression 'a%b' where a<0 and b>0 will return a negative
> result (K&R lets this be machine dependent).
>
That would probably be driven by architecture. The idea is that a % b would
compile to a single machine instruction (on K and R's original platform).
Just a guess, but I suspect this is the motivation.
- Next message: Sean Hamilton: "Correct type for array indices"
- Previous message: sam1967_at_hetnet.nl: "Re: PORTING GMP PROGRAMS TO WINDOWS"
- In reply to: Rennie deGraaf: ""Interesting" C behaviours"
- Next in thread: Rennie deGraaf: "Re: "Interesting" C behaviours"
- Reply: Rennie deGraaf: "Re: "Interesting" C behaviours"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|