What is a boolean data type?

Discussion in 'C++' started by Pep, Nov 28, 2006.

  1. Pep

    Pep Guest

    This is getting weird. I have to keep moving between visual c and gnu
    c++ compilers and now have come across a problem that seems to relate
    to the boolean datatype.

    I have a method that is defined as

    boolean isOkay(string var)
    {
    ... some code ...

    return(true);
    }

    But this seems to not be working properly.

    So I did a quick investigation of the boolean adta type and can find
    nothing for it. I can find the following

    bool = original C
    Boolean = C++
    BOOLEAN = not sure

    So what is boolean and why does it now work the same as bool, or
    Boolean or BOOLEAN?

    TIA,
    Pep.
    Pep, Nov 28, 2006
    #1
    1. Advertising

  2. Pep wrote:
    > This is getting weird. I have to keep moving between visual c and gnu
    > c++ compilers and now have come across a problem that seems to relate
    > to the boolean datatype.
    >
    > I have a method that is defined as
    >
    > boolean isOkay(string var)
    > {
    > ... some code ...
    >
    > return(true);
    > }
    >
    > But this seems to not be working properly.
    >
    > So I did a quick investigation of the boolean adta type and can find
    > nothing for it. I can find the following
    >
    > bool = original C
    > Boolean = C++
    > BOOLEAN = not sure


    I would disagree with all three. AFAIK C has no bool type,
    the C++ type is 'bool' and Microsoft's type is 'BOOL'.

    > So what is boolean and why does it now work the same as bool, or
    > Boolean or BOOLEAN?


    Stick to bool, that's the standard C++ type.

    HTH,
    - J.
    Jacek Dziedzic, Nov 28, 2006
    #2
    1. Advertising

  3. Pep

    Guest

    bool
    This keyword is a built-in types in the standard c++, (should be true
    or false)

    BOOLEAN
    Boolean variable (should be TRUE or FALSE).
    This type is declared in WinNT.h as follows:
    typedef BYTE BOOLEAN;
    , Nov 28, 2006
    #3
  4. Pep

    Pep Guest

    wrote:
    > bool
    > This keyword is a built-in types in the standard c++, (should be true
    > or false)
    >
    > BOOLEAN
    > Boolean variable (should be TRUE or FALSE).
    > This type is declared in WinNT.h as follows:
    > typedef BYTE BOOLEAN;


    Thanks to everyone, as suspected I'll stick to the c++ type.

    Incidentally it turns out the boolean type is working correctly, the
    problem with the code is further down the source deck, go figure :)

    Cheers,
    Pep.
    Pep, Nov 28, 2006
    #4
  5. Pep

    Ron Natalie Guest

    wrote:
    > bool
    > This keyword is a built-in types in the standard c++, (should be true
    > or false)
    >
    > BOOLEAN
    > Boolean variable (should be TRUE or FALSE).
    > This type is declared in WinNT.h as follows:
    > typedef BYTE BOOLEAN;
    >


    Which in fact, is not a boolean. It's a char which
    has the old C behavior of zero for false, anything else
    for true.
    Ron Natalie, Nov 28, 2006
    #5
  6. Pep:

    > boolean isOkay(string var)



    If I'm not mistaken, the type in question is called "boolean" in Java, and
    "bool" in C++.

    There's no such things as "boolean", "BOOLEAN" or "BOOL" in Standard C++.

    --

    Frederick Gotham
    Frederick Gotham, Nov 28, 2006
    #6
  7. Jacek Dziedzic wrote:
    > Pep wrote:
    >> This is getting weird. I have to keep moving between visual c and gnu
    >> c++ compilers and now have come across a problem that seems to relate
    >> to the boolean datatype.
    >>
    >> I have a method that is defined as
    >>
    >> boolean isOkay(string var)
    >> {
    >> ... some code ...
    >>
    >> return(true);
    >> }
    >>
    >> But this seems to not be working properly.
    >>
    >> So I did a quick investigation of the boolean adta type and can find
    >> nothing for it. I can find the following
    >>
    >> bool = original C
    >> Boolean = C++
    >> BOOLEAN = not sure

    >
    > I would disagree with all three. AFAIK C has no bool type,


    <OT>
    FYI: As of C99, C does have a built in boolean type, it's called
    "_Bool", or after you include <stdbool.h>, "bool" (i.e. same name as in
    C++).
    </OT>

    --
    Clark S. Cox III
    Clark S. Cox III, Nov 28, 2006
    #7
  8. Clark S. Cox III wrote:
    > Jacek Dziedzic wrote:
    >> Pep wrote:
    >>> This is getting weird. I have to keep moving between visual c and gnu
    >>> c++ compilers and now have come across a problem that seems to relate
    >>> to the boolean datatype.
    >>>
    >>> I have a method that is defined as
    >>>
    >>> boolean isOkay(string var)
    >>> {
    >>> ... some code ...
    >>>
    >>> return(true);
    >>> }
    >>>
    >>> But this seems to not be working properly.
    >>>
    >>> So I did a quick investigation of the boolean adta type and can find
    >>> nothing for it. I can find the following
    >>>
    >>> bool = original C
    >>> Boolean = C++
    >>> BOOLEAN = not sure

    >> I would disagree with all three. AFAIK C has no bool type,

    >
    > <OT>
    > FYI: As of C99, C does have a built in boolean type, it's called
    > "_Bool", or after you include <stdbool.h>, "bool" (i.e. same name as in
    > C++).
    > </OT>


    Thanks, I forgot C keeps evolving. :)

    - J.
    Jacek Dziedzic, Nov 30, 2006
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike Newton
    Replies:
    0
    Views:
    2,634
    Mike Newton
    Jul 27, 2004
  2. Ramprasad A Padmanabhan

    using char as boolean data type

    Ramprasad A Padmanabhan, Sep 1, 2003, in forum: C Programming
    Replies:
    10
    Views:
    618
  3. KimmoA

    The lack of a boolean data type in C

    KimmoA, Dec 19, 2006, in forum: C Programming
    Replies:
    76
    Views:
    1,385
    Malcolm McLean
    Jan 6, 2007
  4. J Leonard
    Replies:
    4
    Views:
    12,620
    Mark Space
    Jan 19, 2008
  5. Metre Meter
    Replies:
    7
    Views:
    354
    Metre Meter
    Aug 6, 2010
Loading...

Share This Page