What is a boolean flag

26,000

Solution 1

In general, "Flag" is just another term for a true/false condition.

It may have more specific meanings in more specific contexts. For instance, a CPU may keep "arithmetic flags", each one indicating a true/false condition resulting from the previous arithmetic operation. For instance, if the previous operation was an "ADD", then the flags would indicate whether the result of the add was zero, less than zero, or greater than zero.

I believe the term comes from flags used to signal a go/no go condition, like, a railroad flagman indicating whether or not it is safe for the train to proceed.

Solution 2

You hear this quite a bit with BOOL being a 'Flag' since there are only 2 outcomes either TRUE or FALSE. Using BOOL in your decision making processes is an easy way to 'flag' a certain outcome if the condition is met.

An example could be:

if ($x == TRUE) {
 // DO THIS
{
else {
 //Flag not tripped, DO THIS
}
Share:
26,000
swydell
Author by

swydell

I'm in my last year at Long Beach city College in Long Beach California. I went around the world and now I'm taking a basic programming concepts course. My major is web development and design with intentions to transfer to a 4 year college after graduations. I began in 2011 taking web design courses but I have since drawn more toward computer programming. I'm having a difficult time with intermediate algebra. At 72 years old I wonder why am I doing this, whose going to hire me? What company is going to invest in a 72 year old man? But I press on because I don't believe in quitting.

Updated on October 03, 2020

Comments

  • swydell
    swydell over 3 years

    I'm taking a course in Visual Basic 2010 and I'm trying to get a grasp on this new term called a flag. I kind of understand that it has something to do with a boolean condition. I don't quite understand what a flag is. I see references to it using the term flag. I understand it has something to do when a boolean, a condition triggers a flag. But what is the flag. How do you identify it? Can somebody give me an example.

  • xXPhenom22Xx
    xXPhenom22Xx over 12 years
    Correct PHP, I dont mess with .NET just trying to give a very basic example all could understand
  • xXPhenom22Xx
    xXPhenom22Xx over 12 years
    Here is probably a more appealing thread from an MSDN site using VB.net and BOOLEAN... Hope this helps social.msdn.microsoft.com/Forums/en-CA/vblanguage/thread/…