RE: [avr-gcc-list] C coding question

2006-10-10 Thread Eric Weddington
> -Original Message- > From: > [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > org] On Behalf Of Paulo Marques > Sent: Monday, October 09, 2006 4:39 AM > To: larry barello > Cc: avr-gcc-list@nongnu.org > Subject: Re: [avr-gcc-list] C coding questi

Re: [avr-gcc-list] C coding question

2006-10-09 Thread Paulo Marques
larry barello wrote: [...] So I said: (bSomeBool?1:0) ^ ((SomeBitMask & SomeVariable)?1:0)) Since no one else made this comment, I just wanted to point out that you can write that as: (bSomeBool ^ (!!(SomeBitMask & SomeVariable))) "!!" is often used to convert an integer value into a logic

Re: [QUARANTINE] Re: [avr-gcc-list] C coding question

2006-10-06 Thread Joerg Wunsch
"Larry Barello" <[EMAIL PROTECTED]> wrote: > There doesn't appear to be "stdbool.h" as part of WinAvr, ... Of course, there is. Common pitfall: the AVR-GCC installation ships with *two* (disjunct) sets of header files. One set is part of the GCC installation, and things like belong to that gro

RE: [QUARANTINE] Re: [avr-gcc-list] C coding question

2006-10-06 Thread Larry Barello
L PROTECTED] On Behalf Of Tom Deutschman Sent: Friday, October 06, 2006 6:17 AM To: avr-gcc-list@nongnu.org Subject: [QUARANTINE] Re: [avr-gcc-list] C coding question Importance: Low I agree with Nigel, but yes, (!0 == 1). Quoted from C Programming Language Reference Manual section A7.4.7 The

Re: [avr-gcc-list] C coding question

2006-10-06 Thread Royce Pereira
Hi, On Fri, 06 Oct 2006 13:39:36 +0530, Nigel Winterbottom <[EMAIL PROTECTED]> wrote: >> -Original Message- >> From: larry barello > >> Specifically I was looking for an efficient way to encode >> >> (bSomeBool ^ (SomeBitMask & SomeVariable)) >> >> to get a true/false output. > --

Re: [avr-gcc-list] C coding question

2006-10-06 Thread Tom Deutschman
I agree with Nigel, but yes, (!0 == 1).Quoted from C Programming Language Reference Manual section A7.4.7 The operand of the ! operator must have arithmetic type or be a pointer, and the result is 1 if the value of its operand compares equal to 0, and 0 otherwise. The type of the result is int.

RE: [avr-gcc-list] C coding question

2006-10-06 Thread Nigel Winterbottom
> -Original Message- > From: larry barello > Specifically I was looking for an efficient way to encode > > (bSomeBool ^ (SomeBitMask & SomeVariable)) > > to get a true/false output. Does it have to be an expression ? If not, what's wrong with: if (SomeBitMask & SomeVariable) b

Re: [avr-gcc-list] C coding question

2006-10-05 Thread Joerg Wunsch
"larry barello" <[EMAIL PROTECTED]> wrote: > when mixing bit-wise and logical operations, is it safe to assume > that (!0 == 1) is true? I think it is, but would have to look it up in the standard. Use , the type "bool", and the values "true" and "false" instead. That's the C99 approach. -- c