From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9107 invoked by alias); 19 Aug 2008 16:34:14 -0000 Received: (qmail 9099 invoked by uid 22791); 19 Aug 2008 16:34:14 -0000 X-Spam-Check-By: sourceware.org Received: from perm68-235.ij.net (HELO smirk.3gfp.com) (209.216.68.235) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 19 Aug 2008 16:33:19 +0000 Received: from localhost (localhost [127.0.0.1]) by smirk.3gfp.com (Postfix) with ESMTP id AF6CC9B1F45 for ; Tue, 19 Aug 2008 12:33:16 -0400 (EDT) Received: from smirk.3gfp.com ([127.0.0.1]) by localhost (smirk.3gfp.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id RDMZUujUO-Yu for ; Tue, 19 Aug 2008 12:33:13 -0400 (EDT) Received: from harveybook.swlocal (sw.contech.com [64.132.158.194]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smirk.3gfp.com (Postfix) with ESMTP id 069F79B1F15 for ; Tue, 19 Aug 2008 12:33:12 -0400 (EDT) Message-ID: <48AAF5C8.7010909@3gfp.com> Date: Tue, 19 Aug 2008 16:45:00 -0000 From: Richard Harvey Chapman User-Agent: Thunderbird 2.0.0.16 (Macintosh/20080707) MIME-Version: 1.0 To: gcc Subject: Re: regarding type promotion References: <48AA5377.9080001@redpinesignals.com> <1219162574.6008.7.camel@bob-desktop> In-Reply-To: <1219162574.6008.7.camel@bob-desktop> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-08/txt/msg00174.txt.bz2 Bob Plantz wrote: > Another rule I gave them is "multiplication and division have higher > precedence than addition and subtraction; use parentheses in all other > cases." ++ I used to always get tripped up in embedded code because "==" has precedence over "&" which I do not believe is intuitive to most people. unsigned int value; #define BITSET 0x1234 // Wrong: always true if value is odd since BITSET == BITSET is evaluated first // which reduces to "(value & 1)" if (value & BITSET == BITSET) {} // Bits are set // Right: if ((value & BITSET) == BITSET) {} // Bits are set