A Boolean data type is a data type with only two possible values: true or false.


A data type that represents an integer

Value efficient existence

Quality Example
More efficient

"I always assumed that boolean were more efficient than int at storing an on off value - considering that s their reason for existence"

from question "Boolean vs Int in Javascript"

More space

"Would a boolean array of size 32 take more space than an int variable for example"

from question "Does a boolean array take more space than a number of the same size?"

Less space

"It is saying this because using the int to store the value 32 bits is going to use less space than a boolean 256 as each allocated boolean will take up 8 bits 8 256 2048"

from question "Java: bit vector vs. boolean array"

Time a.length consuming

Quality Example

"However the second loop causes the additional task of casting each of the values between a.length and 0 to a boolean which is more time consuming than int comparison"

from question "Why is there a performance difference between these two reverse loops?"

More time

"Since the logic is the same i thought evaluating boolean objects takes more time than int equivalence true 1 and false 0 therefore i came up with the following benchmark and it turns out that i was correct"

from question "Why evaluating boolean objects takes time in python"

Memory heap space

Quality Example
More memory

"Int occupy more memory than boolean so the heap got corrupted"

from question "HEAP CORRUPTION DETECTED: after Normal block (#143)"

Less space

"A boolean takes less space than an int"

from question "Advantages of BooleanProperty in GAE NDB"

Type numeric better

Quality Example

"Perhaps using int type if values are all numeric would work better than boolean for a and b"

from question "Boolean Array Value Comparison"

Array more

"But counting the number of trues in a boolean array is more difficult since the accumulated type int differs from the source type bool"

from question "LINQ Aggregate algorithm explained"


Quality Example
True more meaningful

"Boolean true is more meaningful than int or chars 1"

from question "Java performance - the fastest 'boolean' would be?"


"There is one case when boolean or int works better than boolean and int"

from question "What is the difference between Boolean.TRUE and true in Java?"

"Also your examples about why int would be better than boolean are kinda flawed"

from question "When are booleans better than integers?"

Better performance

"A boolean would most likely not yield better performance than int since the excel formula engine is dynamically typed"

from question "Which is faster in Excel, an if formula giving 1 or 0 instead of true/false or --?"


"Since your patterns are just 0 and 1 values you can think of them as numeric values long is a 64bit int which is more than enough which can be converted later to a boolean matrix"

from question "Optimal Square Covering in 2D Matrix (Minimize Coverage Cost)"

"You can encode up to 32 boolean in an int as follows the method won t error on more than 32 boolean s but won t be able to unpack correctly"

from question "Array of booleans into one numeric and back"

More meaningful

"From the link which is mentioned in question my question is that microsoft says the c# type keywords and their aliases are interchangeable but why we need aliases from my point of view boolean is more meaningful then bool and int32 is more meaningful then int then why aliases"

from question "Why Boolean And bool"

Longer last case

"But wait it s not really constant for boolean arrays and why does int array indexing take longer last case than boolean array indexing even if it has to process 5 times less elements"

from question "Performance of various numpy fancy indexing methods, also with numba"


"The int version seems to execute much faster than the boolean one"

from question "Integer vs Boolean array Swift Performance"

Operation quite longer

"So boolean operation is quite longer than for int or float"

from question "Why operation on boolean are slower than on other types in numpy?"


"Which is invalid as a boolean cannot be less than an int"

from question "Why its wrong in java:"

"Keep in mind that depending on the use and on the system using it while a boolean takes less space because it s just a single bit depending on the implementation an int is the native word size of the hardware"

from question "When are booleans better than integers?"


"If the boolean value is true and the length of the string is greater than the int value print the sum of the float and the int"

from question "Unorderable types: str() > int() python"

Back to Home
Data comes from Stack Exchange with CC-BY-SA-3.0