The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM
Home Forums Register Rules & FAQ Members List Arcade Search Today's Posts Mark Forums Read


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.


Other UNIX.COM Threads You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Bitwise negation dLloydm Shell Programming and Scripting 3 05-17-2007 10:57 AM
resetting counter using bitwise XOR mrgubbala High Level Programming 1 09-14-2006 01:58 AM
bitwise operators areef4u UNIX for Advanced & Expert Users 9 08-04-2006 05:39 AM
Bit-fields and Bitwise operators amatsaka High Level Programming 3 04-23-2002 05:13 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-26-2008
Registered User
 

Join Date: Apr 2008
Posts: 30
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
bitwise and if

Hi

Suppose we have these code lines:

#define _IN_USE 0x001 /* set when process slot is in use */
#define _EXITING 0x002 /* set when exit is expected */
#define _REFRESHING 0x004

...
1 main () {
2
3 unsigned r_flags =_REFRESHING;
4
5 if (r_flag & _IN_USE){
6 if (r_flag & _EXITING){
7 printf("EXITING");
8 }
9 if (r_flag & _REFRESHING){
10 printf("REFRESHING");
11 }
12 }
13 }

Will i see on the screen the string REFRESING ? (line 10)
Can I say that REFRESCHING and EXITING are two particular cases of the more generic IN_USE?
Than you in advance
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 04-26-2008
Registered User
 

Join Date: Apr 2008
Posts: 30
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
I tried on my own and I can say that
given that code lines, the line 10 will never be active because the condition in in the if at line 5 can't be true since REFRESING is 0100 (low foru bits) while IN_USE 0001
it could be true if REFRESING = 01001.
So I can't say that EXITING and REFRESHING are two particular cases of IN_USE but they are different cases.
Are you agree with me?
Reply With Quote
  #3 (permalink)  
Old 04-28-2008
Registered User
 

Join Date: Oct 2007
Location: USA
Posts: 356
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
Quote:
Originally Posted by Puntino View Post
I tried on my own and I can say that
given that code lines, the line 10 will never be active because the condition in in the if at line 5 can't be true since REFRESING is 0100 (low foru bits) while IN_USE 0001
it could be true if REFRESING = 01001.
So I can't say that EXITING and REFRESHING are two particular cases of IN_USE but they are different cases.
Are you agree with me?
Yes it would be correct to say that the REFRESHING / EXITING cases are the different states a process slot can be in though they are not particular cases of the IN_USE state as proven by the bitwise ANDing of the various process slot states.
Reply With Quote
  #4 (permalink)  
Old 04-28-2008
Registered User
 

Join Date: Apr 2008
Posts: 30
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
thank you, shamrock
Reply With Quote
Google UNIX.COM
Reply



Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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



All times are GMT -7. The time now is 02:29 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger

Search Engine Optimization by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102