bool and BOOL
-
if you're coding in C,
bool
just don't exist (I prefer mention it, even it's obvious). in C++,bool
is a native type. it weights 1 byte and takes the values0_b_0000000**1**
(true
) or0_b_0000000**0**
(false
). you can assign an integer to abool
. if it is different from0
, it equals the value "true
", and will be automatically converted into0_b_0000000**1**
anyway.BOOL
is different. it is anenum
type inherited from the old C days. it's definition is like this :enum BOOL {
FALSE = 0,
TRUE
};An
enum
is actually anint
, which mean it weights 4 bytes (on a 32 bits system). apparently, Microsoft implements it in a different manner, so you have to be much more careful with it. for instance ://if defined like this :
typedef int BOOL;//this can be a mistake :
BOOL b = 4;
if (b == true) {
//never enters here
// because 4 != 1
}[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
modified on Tuesday, May 20, 2008 9:50 AM
toxcct wrote:
if you're coding in C, bool just don't exist
It did not exist in C89, but exists in C99[^]
-
toxcct wrote:
doesn't a Byte having 8 bits
Yes, so it is coded 0x00 to 0xFF (hexa representation) or 0b00000000 to 0b11111111 (binary representation).
Cédric Moonen Software developer
Charting control [v1.4]yes yes, fixed already ;)
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
-
Rajesh R Subramanian wrote:
May be toxcct is on drugs today for a change
come on, have you ever worked under linux ? Microsoft IS NOT the standard, even if 85% of the PCs worldwide are windows based... :doh:
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
toxcct wrote:
have you ever worked under linux
What kind of drug is that ? ;P
Cédric Moonen Software developer
Charting control [v1.4] -
toxcct wrote:
have you ever worked under linux
What kind of drug is that ? ;P
Cédric Moonen Software developer
Charting control [v1.4]Cedric Moonen wrote:
What kind of drug is that ?
i'd better give up there ! lol
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
-
hai all, about 'bool' i got idea... from all ur replies... but what about BOOL..? i am not clear...
Born to win...!
modified on Tuesday, May 20, 2008 11:57 PM
BOOL is fully featured integer, for instance, you can do.
// WEIRD BOOL (legal) programming
BOOL b;
b = 1000;
b++;You can't do the same with a
bool
variable. [added] Well, I made a sanity check, and actuallyVC++
compiler gives just a warning on the following codebool b;
b = 1000; // Warning here (loss of info), at runtime b becomes true.
b++; // at runtime b remains true.[/added] As stated by someone (Rajesh ? toxcct?) this is a reminiscence of the
C
language gold ol days (C
has not thebool
keyword). Using anint
to representYes/No
pair is simply a matter of convention (and convenience). :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
toxcct wrote:
have you ever worked under linux
What kind of drug is that ? ;P
Cédric Moonen Software developer
Charting control [v1.4]I dunno. Azk CPallini. He'z da one who abuzez drug to answer queris realllly fazzt. He haz gud drugz and gud linkz. azk him plz. :laugh:
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
-
May be toxcct is on drugs today for a change. :laugh:
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
I supposed too. :laugh:
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
BOOL is fully featured integer, for instance, you can do.
// WEIRD BOOL (legal) programming
BOOL b;
b = 1000;
b++;You can't do the same with a
bool
variable. [added] Well, I made a sanity check, and actuallyVC++
compiler gives just a warning on the following codebool b;
b = 1000; // Warning here (loss of info), at runtime b becomes true.
b++; // at runtime b remains true.[/added] As stated by someone (Rajesh ? toxcct?) this is a reminiscence of the
C
language gold ol days (C
has not thebool
keyword). Using anint
to representYes/No
pair is simply a matter of convention (and convenience). :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarkebut one has to be careful with BOOL, as I stated at the end of my most here[^]
CPallini wrote:
C has not the bool keyword
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
-
but one has to be careful with BOOL, as I stated at the end of my most here[^]
CPallini wrote:
C has not the bool keyword
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
toxcct wrote:
but one has to be careful with BOOL, as I stated at the end of my most here[^]
Indeed.
C
language implicit mapping of non-zero values to true and zero value to false is more coherent.toxcct wrote:
looks like it has[^]
I saw it, but: shhhhhh, noone, except Nemanja, knows. :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
toxcct wrote:
but one has to be careful with BOOL, as I stated at the end of my most here[^]
Indeed.
C
language implicit mapping of non-zero values to true and zero value to false is more coherent.toxcct wrote:
looks like it has[^]
I saw it, but: shhhhhh, noone, except Nemanja, knows. :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain ClarkeCPallini wrote:
I saw it, but: shhhhhh, noone, except Nemanja, knows.
Oh come on. You are a "C" lover. I would have expected you to know. :-D
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
-
CPallini wrote:
I saw it, but: shhhhhh, noone, except Nemanja, knows.
Oh come on. You are a "C" lover. I would have expected you to know. :-D
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
Well, I'm a traditional-
C
lover: that fancy newC99
is alien to me. :laugh:If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
Well, I'm a traditional-
C
lover: that fancy newC99
is alien to me. :laugh:If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain ClarkeThanks for ur kind reply to all members whoever particpated in the discussion., by, Manivannan@Congruent
Born to win...!