C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

What are the codes doing?

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
Skyhorse
Guest





PostPosted: Fri Apr 16, 2004 6:18 am    Post subject: What are the codes doing? Reply with quote



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





PostPosted: Fri Apr 16, 2004 5:06 pm    Post subject: Re: What are the codes doing? Reply with quote



"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





PostPosted: Fri Apr 16, 2004 6:35 pm    Post subject: Re: What are the codes doing? Reply with quote



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





PostPosted: Sat Apr 17, 2004 10:10 pm    Post subject: Re: What are the codes doing? Reply with quote

"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 Wink | 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





PostPosted: Sat Apr 17, 2004 10:44 pm    Post subject: Re: What are the codes doing? Reply with quote

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





PostPosted: Mon Apr 19, 2004 6:43 pm    Post subject: Re: What are the codes doing? Reply with quote

Jakob Bieling wrote:

Quote:
What are the meaning of & 0xffe00000, & 3, 0xf, 0x3?

& is the bitwise or operator.


Guess that is a typo Wink | 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
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.