answersLogoWhite

0


Best Answer

There are a number of data types that we use in computer science. Bool data type stands for boolean data type. In boolean data type the data is stored in form of 0 ans 1s. On boolean data type logical functions like AND, OR ,NOT ,XOR etc functions can be performed.

User Avatar

Wiki User

βˆ™ 9y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

βˆ™ 11y ago

A bool data type is a variable that is interpreted as being true if its value is non-zero, and false if it is zero. Although it only has two possible states and can conceivably occupy just 1 bit, it actually uses 8 bits and is effectively the same as a signed char. The value 0x00 (0) is always false while 0xFF (-1) is typically true but any non-zero value is regarded as being true.

For a single boolean, 8-bits is fine, but if you have several boolean values it can be more efficient to use a bitmap where each bit represents a separate boolean value. Thus a 32-bit int can store a bitmap containing up to 32 boolean values. Using the standard bool would require up to 32 bytes, which quickly adds up if you have many objects with many bools.

To determine the state of individual bits in a boolean bitmap you use the bitwise AND operator (&) to compare the bitmap with individual hex values 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40 and so on, for each bit from the right. Thus to check the forth bit from the right, you return the evaluation of bitmap & 0x8. If the result is zero, the bit is not set. If the result is 0x8 (or simply non-zero), then the bit is set.

You can also check for multiple values by bitwise ORing the individual values. Thus bitmap & ( 0x01 | 0x02) returns 0x00 if neither of the first two bits are set, 0x01 if the first bit is set, 0x02 if the second is set and 0x03 if both are set.

This answer is:
User Avatar

User Avatar

Wiki User

βˆ™ 12y ago

Boolean data is either 0 or 1. You can perform logical operations such as AND, OR and NOT on this data type.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What Is bool data type?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How many bytes are allocated in the bool data type?

bool (lowercase, built-in type) has an unspecified size, but is typically 1 byte. When in doubt, use sizeof( <type> ) to determine the byte count of any data type.


Which data type stores only one of two values?

In Java, such a data type is called boolean. In other programming languages it may be known by different names, including variations of "boolean" such as "bool", and "logical".


What Lead to C C plus plus and java?

(C and Lisp, ... data type") was adopted by many later languages, such as ALGOL 68 (1970), Java, and C#. ... C++ has a separate Boolean data type ( 'bool' ), but with automatic conversions from ... "Report on the Algorithmic Language ALGOL 68


What are the advantages of having various data types for example what is the advantage of having an integer or boolean data type in programming...please answer a.s.a.p?

The various datatypes allow the developer to describe how the data is to be stored inside a program. It also allows the developer or the reader/maintainer of the code to understand the maximum and minimum values that may be stored there. In some cases, the 'bool' type for example, indicate how the data is to be used. A bool variable may have only 1 of two possible values, either true or false. An int (or any variant of int) may not contain fractional values, and so on.


What are the nine basic data types?

Byte Short Int Long Float Double Char Bool String


When did Henry Bool die?

Henry Bool died in 1922.


When was Choi Bool-am born?

Choi Bool-am was born on 1940-06-15.


When was Al Bool born?

Al Bool was born on 1897-08-24.


When did Al Bool die?

Al Bool died on 1981-09-27.


Program to do for cplusplus that needs the else if ladder can you tell you how to do that?

if (bool expression 1){...}else if (bool expression 2){...}else if (bool expression 3){...}


What is the C plus plus code using Boolean value as output?

The question is not clear. If you mean can you write a C++ program such that the main function returns a boolean, the answer is no, you cannot. The main function must return an int to the operating system. However, the return value can be treated as boolean such that non-zero indicates true (an error has occurred) and zero indicates false (no error). Unlike C, C++ does include a primitive bool data type which can only be true or false. All the comparision operators such as ==, !=, <, <=, > and >= return bool and all the integral data types (int, char, wchar_t) can be implicitly converted to and from bool. Converting a bool to an int returns the value -1, since false is typically imlemented with all bits set while true is implemmented with all bits unset.


What is boolean in C Sharp?

A boolean is a variable type that can only be two different values True or False same as it is in most programming languages but in C# booleans are stated as: public bool var = True; or public bool var = False;