473,406 Members | 2,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Simple question regarding If and bools.... just to clear any doubts I have!

VMI
I'm having doubts as to how the compiler interprets this If statement:

bool bIsTrue = true;

if (! bIsTrue)
{
//RUN PROCESS
}

Here, will "RUN PROCESS" be executed? Or is this just wrong? How is this
really interpreted by the compiler?

Thanks.
Nov 17 '05 #1
2 1292
Read it like this

if (not True)
//RUN PROCESS

....same as...
if(bIsTrue == false)
//RUN PROCESS

"VMI" <vo******@yahoo.com> wrote in message
news:OD***************@tk2msftngp13.phx.gbl...
I'm having doubts as to how the compiler interprets this If statement:

bool bIsTrue = true;

if (! bIsTrue)
{
//RUN PROCESS
}

Here, will "RUN PROCESS" be executed? Or is this just wrong? How is this
really interpreted by the compiler?

Thanks.

Nov 17 '05 #2
Hi VMI,
the if statement will enter the if section only if the conditional
statement evaluates to true.

so if you write:

if(true)
{
//will always come here
}
else
{
//will never get here
}

the top section will always get entered because the conditional always
evaluates to true. Conversely if you write:

if(false)
{
//will never go here
}
else
{
//will always go here
}

the if statement always evaluates to false, so the else will always be
entered.

So for your code:
bool bIsTrue = true;

if (! bIsTrue)
{
//RUN PROCESS
}
this is really saying:

if(NOT TRUE)
{
}

which is equivalent to

if(FALSE)
{
//will never go here
}
Hope that helps
Mark R Dawson
http://www.markdawson.org

"VMI" wrote:
I'm having doubts as to how the compiler interprets this If statement:

bool bIsTrue = true;

if (! bIsTrue)
{
//RUN PROCESS
}

Here, will "RUN PROCESS" be executed? Or is this just wrong? How is this
really interpreted by the compiler?

Thanks.

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: JC | last post by:
Hi - I'm currently learning PHP using the ORA "cuckoo" book. I'm looking for some reasonably interesting sample code to read and thought that a *simple* Wiki could be ideal. Can anyone recommend...
6
by: ritesh | last post by:
Hi, I have been reading some text on C and C++ (i.e advanced books). One of the books mentioned that C++ requires a runtime support whereas C does not - what the author was trying to say was...
5
by: Davie | last post by:
I'm developing an application on the smartphone. To reduce the size of the application i'm using panels where appropriate instead of forms. As a result of the design, I need to have different...
18
by: Frances | last post by:
I want to learn PHP.. I know JSP, Servlets, have been using Tomcat for 2 years now, and even though I know there are ways you can use PHP in conjunction with Tomcat, I'd rather not tinker with...
4
by: Russell Warren | last post by:
I'm guessing no, since it skips down through any Lock semantics, but I'm wondering what the best way to clear a Queue is then. Esentially I want to do a "get all" and ignore what pops out, but I...
0
by: derelict | last post by:
Hey all, im getting desperate now. I have a macro running in Word 2003, when I run the macro it *should* put a 'bottom' cell border in each cell that has the style used - this included a border at...
5
by: Michael Goldshteyn | last post by:
Consider the following two lines of code, the first intended to print "Hello world\n" and the second intended to print the character 'P' to stdout. --- std::cout <<...
2
by: jonKushner | last post by:
So, after the long debate about using ANY sort of external packaged library besides my own hacked scripts, I decided to dig through the source code of ZF and peek around. I was pretty impressed....
4
by: samuel123 | last post by:
Greetings All, Once again back to this forum. I have got a problem and hope to get solution. Senario.. I have a table called users, it has following fields user_name ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.