?
Solved

What does "If(!(CurValue & 0X8000))" mean

Posted on 1998-03-03
4
Medium Priority
?
314 Views
Last Modified: 2011-10-03
Should be a easy 20 points for you.
Can someone tell me what it means in english?
0
Comment
Question by:JHBrother
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 80 total points
ID: 1182964
Answer coming.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1182965
First of all, I assume you are asking about

If(!(CurValue & 0X8000))

not

&If(!(CurValue & 0X8000))&

 I think there are two extra &"s which I beleive are a typo, or are an HTML artifact.  If I am wrong, post a longer example  (for text from before and after).

starting inside and working out (which is how it will be executed)  

The compiler does a bitwise and of CurVal 0x8000.  Assuming this is 32 bit code, 0X8000 is a value with the high bit set.  So this code returns a non-zero value (true) if  CurValue's high bit is set.  It returns a zero value (false) if CurValue's high bit is clear.

This value is inside "!( )" so the compiler toggles it from true to false.  Thus now we have true if CurValue's high bit is clear.  False if it is set.

This goes into the if().  If you are not familiar with if's, then the "if statements" will execute if CurValue's high bit is clear.  The "else statements" (if there are any) will execute if CurValue's high bit is set.

0
 

Author Comment

by:JHBrother
ID: 1182966
Thank you.
This is what the program looks like (in C++)
currVal = GetRecInt()
Trans = (Double)MASK(CurVal)- (double)Dark
If (!(CurrVal& 0X8000))
      Trans /=Factor;

CurrVal is of two bytes (16 bits)

0
 
LVL 22

Expert Comment

by:nietod
ID: 1182967
That's what i thought it would look like and it is what I described.  (Your title has extra &'s, or at least it does on my browser, and that threw me a little.

I said 32 bits in my answer, but I meant 16 bits.  Force of habit.  Haven't dealt with 16bit code in over a year.

Does this make sense to you now?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question