Boolshit

I was wondering why datatype bool was invented in the first place when you can check true or false with just int x = 0/ int x = 1... why the hell? You can actually make logical operations with positive/negative numbers.. i just don't understand that crap. Its fucking boolshit.

Other urls found in this thread:

stackoverflow.com/questions/4626815/why-is-a-boolean-1-byte-and-not-1-bit-of-size
twitter.com/NSFWRedditImage

Is this an actual question or just a shitpost where you give away the pun in the thread title

Uses less memory, less confusion in your code. It helps stop things from getting too complex, and makes the value less mutable as opposed to an int. And frankly, it helps me remember the purpose of the variable.

BOOGER!

an actual question, what the fuck are you talking about?
>uses less memory
useful for calculators but not for modern computers, bool datatype is not one bit/byte as it should be
>it helps me remember the purpose of the variable.
...... i dont know what to say on this one

>I was wondering why datatype bool was invented in the first place when you can check true or false with just int x = 0/ int x = 1... why the hell?

true / false = 1 bit
X = variable, but usually minimum 1 byte (8 bits).

Because you didn't have 256gb RAM when computing was invented. You had wardrobe sized monsters that cost $1000 per megabyte to be leased.

Every single bit counted.

also, boogerman was a fun game.

because the boolean data type means the system only needs to reserve on single bit in the ram where a integer could be any length and require way more

are you stupid?

>true / false = 1 bit
WRONG
CPU can't address anything smaller than a byte.
stackoverflow.com/questions/4626815/why-is-a-boolean-1-byte-and-not-1-bit-of-size

It's not one bit true, but the compiler/computer is clever enough to assign 8 bool variables to one byte with each variable taking a single bit.

Wow, that is pretty cool.

This kind of low quality post killed Sup Forums.

>[citation needed]

jesus christ you people are idiots
it was abstracted from bits to a data type for the sake of portability between architectures

What compiler are you using? Just look at the ASM it outputs

>>it helps me remember the purpose of the variable.
>...... i dont know what to say on this one

>I always remember everything I've ever typed, every variable I've ever declared since I've started programming.

Bruh

That would actually be quite useless in most use cases, because it would decrease the memory consumption at the cost of increasing the execution time, which is a bad trade-off, since you use loops involving bools, where the execution time actually matters, more often than you use large arrays of bools. And if you need really humongous arrays of bools for some strange reasons, you can either write your own custom shit, or use the compiler's built in space-optimization for large "arrays" of bools, such as C++'s std::vector.

You could use it to implement logic based on a variable's type. if a is boolean, then this.

>Actually, the four x86 instructions bt, bts, btr and btc can address single bits!
lrn2read

GCC doesn't do 1bit bools not even when compiling with memory optimization.

The size of bool in C99 is char.

>CPU can't address anything smaller than a byte.
That's not the same as saying gcc doesn't optimize for instructions that can read one bit.

>"hey user, pretty hot today huh?"
>"yeah, so 1"

because expressing intent through typing is important to writing comprehensible code

Retards. A Boolean is 8 bits.

legibility. Stop being butthurt and use whatever you want, but use boolean if you want to work with other people.

char x;
x&(1

>...... i dont know what to say on this one

You say, "I've never worked on a project larger than my 1000 loc personal projects."

kek

m8, are you seriously getting triggered by a data type? You need to get it together.