Stop using Booleans
Stop using Booleans
Other urls found in this thread:
asktom.oracle.com
tutorialspoint.com
bbc.com
reddit.com
twitter.com
false
what if i want to store a single bit value and nothing more?
& (1
#define prop 1
Bit fields.
You're still talking up a byte of memory lmao
Use bit field bool when you're in a struct or class. And regular bool when you only need one option. Anything else, twiddle bits.
Realistically no programming job requires this level of autism in 2019
stdbool.h is a gift to mankind. No.
>lol why bother with optimization bro, memory is cheap
This mindset is why Electron exists
your CPU is byte addressable, not bit addressable. You cannot store/access values smaller than 1 byte. I dont even know if bit addressable CPUs exist
so what do I use instead
IIRC connection machines had 1-bit processors.
java.utils.TrueOrFalseManagerImplementation
TrueFalseAbstractFactoryBean trueorfalse = (TrueFalseAbstractFactoryBean) context.getBean("&TrueFalseAbstractFactoryBean")
>not using tristate
TriState.UseDefault my nibba
no u
const _Bool gender;
What about LOGICALs?
They can be true, false, yes, no, or ?
>It's still the 80s
Get with the times, grandpa.
Knock that off
we use them all the time on the software i work on, and i guarantee you've used that software in the past hour at least indirectly
>_Bool
#include
damn kids, isn't it past your bedtime?
>not using a long long and casting char TRUE = '@' and char FALSE = '#' into it.
You know bitmasks exist right? You can effectively access any single bit you want for the most part just not directly.
Fuck you.
asktom.oracle.com
Never again. "T", "F" and "Y", "N" and 1, 0 and "1", "0" and so on and so forth are all valid methods for representing Boolean values in the multi billion dollar, most popular commercial RDBMS on earth. Retard shit like "don't use Booleans, just use X and Y" is how you end up with pointless fragmentation. Boolean datatypes force people to use the same implementation of the idea of a Boolean. Is it the same shit as 0 and 1? God damn right. But I don't have to worry about arguing over my cube wall with Boomer McCuckFace over 0 and 1 vs "true" and "false" because using anything but a boolean in languages that support them is objectively retarded.
>using Oracle as a source
How's the job hunt going? :^)
But you are still just using one bit , the rest will be unused padding in the memory.
I wish there was a high-tier language that didn't fucking do this.
well, you can allocate a byte and use that byte for 8 booleans, one for each bit, by utilizing bitwise AND
java.util.BitSet
Memory aligned by bit has quite a bit more overhead than by bytes. There is a point of diminishing returns.
C doesn't have this problem
VHDL
exactly. other languages shouldn't use it either.
It's the compiler's job to be autistic enough to use individual bits to represent booleans. It can group them by 32s in an int easily when it compiles.
I thought there was a way in c to make a struct to do this. Yep, I was right tutorialspoint.com
is this a serious suggestion
How do you write if statements?
I always add the parentheses because it looks like the condition is sad to not be true.
condition ? true :( false );
Ok
enum CONDITIONAL { TRUE, FALSE};
>my gender is true
>TRUE == 0
>FALSE == 1
You had one job.
>But you are still just using one bit
Most languages test booleans by comparing the whole to zero, not by testing bits.
>he's never programmed in bash
Kek
I read the entire damned write up on Varg
>bbc.com
And after twenty minutes of reading I don't know why he's a meme about things I should stop doing. Someone explain.
exit codes != boolean
DEATH TO ELECTRON!
No.
#define MALE 1;
.
.
.
const bool gender;
obj1.gender = MALE;
obj2.gender = !MALE;
>premature optimisation
Spot the people without jobs
>the devilish wink at the end
heh....nothin personall kid..
This kind of optimisation is strictly forbidden in any multithreaded language. You'd be inventing writes to variables that are never being written to, making correct synchronisation impossible.
I only use booleans.
Stop... or what?
Why ?
no
fpbp
kek
Stop using the number 3.