 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Skyhorse Guest
|
Posted: Fri Apr 16, 2004 6:18 am Post subject: What are the codes doing? |
|
|
What are the following codes doing? What are the meaning of & 0xffe00000, &
3, 0xf, 0x3?
Is there any difference between & 3 and & 0x3?
inline BOOL CheckAudioHeader(DWORD dwHeader)
{
if ( (dwHeader & 0xffe00000) != 0xffe00000)
return FALSE;
if (!((dwHeader >> 17) & 3))
return FALSE;
if ( ((dwHeader >> 12) & 0xf) == 0xf)
return FALSE;
if ( ((dwHeader >> 10) & 0x3) == 0x3)
return FALSE;
#ifdef _WIN32_WCE
if ( ((dwHeader >> 12) & 0xf) == 0x0)
return FALSE;
#endif
return TRUE;
}
Thanks
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Jakob Bieling Guest
|
Posted: Fri Apr 16, 2004 5:06 pm Post subject: Re: What are the codes doing? |
|
|
"Skyhorse" <victoryen (AT) cuhk (DOT) edu.hk> wrote
| Quote: | What are the following codes doing? What are the meaning of & 0xffe00000,
&
3, 0xf, 0x3?
|
They are bitwise-AND operators, followed by integrals (written decimally
or hexadecimally, see below).
| Quote: | Is there any difference between & 3 and & 0x3?
|
No, but there would be a difference between 0x10 and 10. The prefix 0x
means, the following is a hexadecimal number (base 16), so 0x10 would be 16
in our decimal system (base 10).
hth
--
jb
(replace y with x if you want to reply by e-mail)
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Gerhard Menzl Guest
|
Posted: Fri Apr 16, 2004 6:35 pm Post subject: Re: What are the codes doing? |
|
|
Skyhorse wrote:
| Quote: | What are the following codes doing?
|
The code tests whether certain bits are set in a value that has 32 bits
on the Win32 platform.
| Quote: | What are the meaning of & 0xffe00000, & 3, 0xf, 0x3?
|
& is the bitwise or operator. The initial sequence 0x denotes a
hexadecimal literal. If you are not familiar with these concepts, look
up the terms in a C++ introductory text.
| Quote: | Is there any difference between & 3 and & 0x3?
|
No. Both fragments test whether the value of the expression left of them
have the two lowermost bits set. 3 is the decimal, and 0x3 is the
hexadecimal way of specifying the binary constant 00000011.
| Quote: | inline BOOL CheckAudioHeader(DWORD dwHeader)
{
if ( (dwHeader & 0xffe00000) != 0xffe00000)
return FALSE;
if (!((dwHeader >> 17) & 3))
return FALSE;
if ( ((dwHeader >> 12) & 0xf) == 0xf)
return FALSE;
if ( ((dwHeader >> 10) & 0x3) == 0x3)
return FALSE;
#ifdef _WIN32_WCE
if ( ((dwHeader >> 12) & 0xf) == 0x0)
return FALSE;
#endif
return TRUE;
}
|
Gerhard Menzl
--
Humans may reply by replacing the obviously faked part of my e-mail
address with "kapsch".
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Jakob Bieling Guest
|
Posted: Sat Apr 17, 2004 10:10 pm Post subject: Re: What are the codes doing? |
|
|
"Gerhard Menzl" <gerhard.menzl (AT) spambucket (DOT) net> wrote
| Quote: | What are the meaning of & 0xffe00000, & 3, 0xf, 0x3?
& is the bitwise or operator.
|
Guess that is a typo | is the bitwise-or operator and & is the
bitwise-and operator!
regards
--
jb
(replace y with x if you want to reply by e-mail)
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Steve Folly Guest
|
Posted: Sat Apr 17, 2004 10:44 pm Post subject: Re: What are the codes doing? |
|
|
On 16/4/04 7:35 pm, in article 407fb09c$1 (AT) news (DOT) kapsch.co.at, "Gerhard Menzl"
<gerhard.menzl (AT) spambucket (DOT) net> wrote:
| Quote: | What are the meaning of & 0xffe00000, & 3, 0xf, 0x3?
& is the bitwise or operator.
|
No. It is, of course, the bit-wise AND operator.
Picking a (fairly) random page from a google search, this might explain a
few things about bitwise operators...
http://cplus.about.com/library/weekly/aa042203a.htm
Steve.
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Gerhard Menzl Guest
|
Posted: Mon Apr 19, 2004 6:43 pm Post subject: Re: What are the codes doing? |
|
|
Jakob Bieling wrote:
| Quote: | What are the meaning of & 0xffe00000, & 3, 0xf, 0x3?
& is the bitwise or operator.
Guess that is a typo | is the bitwise-or operator and & is the
bitwise-and operator!
|
More like a thinko. How deeply embarrassing.
Gerhard Menzl
--
Humans may reply by replacing the obviously faked part of my e-mail
address with "kapsch".
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|