Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > masks

Reply
Thread Tools

masks

 
 
lezard
Guest
Posts: n/a
 
      06-01-2005
Hello

i_before = 1;
i_after = i_before and a mask;
i_before = (i_after & 0x7) | 0x40; // then i_before == 1

I don't find what mask is applied to i_before at the second line.
Can someone help me?

--
Lezard
 
Reply With Quote
 
 
 
 
Richard Bos
Guest
Posts: n/a
 
      06-01-2005
lezard <(E-Mail Removed)> wrote:

> i_before = (i_after & 0x7) | 0x40; // then i_before == 1


Regardless of anything else, this is impossible. Think about it. How
could _anything_ | 0x40 ever be 1?

Richard
 
Reply With Quote
 
 
 
 
pete
Guest
Posts: n/a
 
      06-01-2005
lezard wrote:
>
> Hello
>
> i_before = 1;
> i_after = i_before and a mask;
> i_before = (i_after & 0x7) | 0x40; // then i_before == 1
>
> I don't find what mask is applied to i_before at the second line.
> Can someone help me?


Any odd number value for mask, will make the comment true.
 
Reply With Quote
 
pete
Guest
Posts: n/a
 
      06-01-2005
pete wrote:
>
> lezard wrote:
> >
> > Hello
> >
> > i_before = 1;
> > i_after = i_before and a mask;
> > i_before = (i_after & 0x7) | 0x40; // then i_before == 1
> >
> > I don't find what mask is applied to i_before at the second line.
> > Can someone help me?

>
> Any odd number value for mask, will make the comment true.


Actually, as Richard Bos stated, there is no value
which when bitwise ORed with 0x40, yields 1.
 
Reply With Quote
 
Michael Wojcik
Guest
Posts: n/a
 
      06-02-2005

In article <(E-Mail Removed)>, pete <(E-Mail Removed)> writes:
> pete wrote:
> >
> > lezard wrote:
> > >
> > > i_before = 1;
> > > i_after = i_before and a mask;
> > > i_before = (i_after & 0x7) | 0x40; // then i_before == 1
> > >
> > > I don't find what mask is applied to i_before at the second line.
> > > Can someone help me?

> >
> > Any odd number value for mask, will make the comment true.

>
> Actually, as Richard Bos stated, there is no value
> which when bitwise ORed with 0x40, yields 1.


True, though there could be a *variable* which, after being bitwise-
ORed with 0x40, evaluates to 1. It would have to have fewer than
seven value bits, so it would have to be a bitfield; and since in the
OP's posted code i_before cannot be the identifier for a bit- field
(which must be part of a struct or union, and so must be the operand
of the "." or "->" operator), it would have to be a macro for one.

(At least I think that's right; corrections cheerfully accepted.)

--
Michael Wojcik http://www.velocityreviews.com/forums/(E-Mail Removed)

Art is our chief means of breaking bread with the dead ... but the social
and political history of Europe would be exactly the same if Dante and
Shakespeare and Mozart had never lived. -- W. H. Auden
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Routing Table masks ciscortp@hotmail.com Cisco 1 06-03-2006 12:38 AM
Creating masks for photographs? john Computer Support 0 10-19-2005 07:27 PM
A technique for compile-time detection of erroneous bit-masks -opinionsrequested Gianni Mariani C++ 0 01-13-2005 07:24 AM
6500 MSFC and HSRP subnet masks GJP Cisco 1 12-09-2004 01:44 PM
Why Wildcard masks Prashant Varghese Cisco 3 11-08-2004 11:19 AM



Advertisments