Size of datatype : Boolean

purushottam

New member
Joined
Apr 26, 2006
Messages
1
Programming Experience
1-3
Hi all,

In .Net framework, Boolean data type took 2 bytes of space in memory.
But, in other languages like c, c++ ... it took only 1 byte.

Can any one tell me why it took 2 bytes instead of 1 byte and tell me what is the default values for true case and false case?

Thxs in advance,
Purushottam.
 
When numeric data types are converted to Boolean values, 0 becomes False and all other values become True. When Boolean values are converted to numeric types, False becomes 0 and True becomes -1.

As for why it takes 2 bytes.. why does other languages use a whole byte when really only a bit is necessary to tell 0/1 true/false on/off etc ? It is probably some inherent thing.
 
Back
Top