Questions tagged [bit]
The bit tag has no summary.
30 questions
2 votes
5 answers
2k views
The size of a byte in platform independent software
When writing platform independent software in C++, can I nowadays safely1 assume that a byte has a size of 8 bits? Or do I have to calculate it like this, for example: #include <climits> std::...
4 votes
3 answers
283 views
Is it possible to store N bits of unique combinations, in N-1 bits? If not; why does MD5 get reprimanded for collissions?
Regarding cryptography and the issue of collisions, I posed a question as to whether it was ever possible to store every single possible combination of a bit array of a particular size, in a bit array ...
2 votes
6 answers
667 views
What is the viability of engineering an integral type with values ranging from -1 to 254? Do types like this even exist?
In software engineering, often developers will utilize three different states of a signed integer, as a trilean: This tends to be quite typical: -1 - Represents something akin to a null pointer, as in ...
-2 votes
2 answers
783 views
Sign Extension, When to stop?
Today, we learnt about sign extension to solve the problem where adding positive number to another positive one gives a negative. But my professor didn't mention at all when we should use it and how ...
1 vote
2 answers
2k views
In C++, Why do bitwise operators convert 8 or 16 bit integers to 32 bit?
Is there a logical reason why the integer is upgraded to 32+ bits? I was trying to make an 8bit mask, and found myself a bit disappointed that the upgrade will corrupt my equations. sizeof( quint8(0)...
1 vote
2 answers
603 views
C++ - BitVector logic
I have implemented a simple bit vector class. However, I have some problems with understanding, how to push data to it. In a standard vector, push_back inserts new element et the end. A similar ...
0 votes
4 answers
2k views
Can int16_t be easier on the processor then int?
I know that the compiler and architecture of a processor also have a role to play in this. But this is more of a "can it" rather then a "does it" question. I have already tried to research this, but ...
56 votes
3 answers
10k views
What is the name for storing / packing many boolean states into one number?
It's a sort of simple compression where you use one numeric variable to store many boolean / binary states, using doubling and the fact that every doubling number is 1 + the sum of all the previous ...
1 vote
2 answers
139 views
Meaning of Using BitVectors to Model Integers to account for Overflow
I have just encountered this sentence: Depending on the context, we may prefer to model integers as bitvectors rather than mathematical integers, since the Int type does not model overflow. I am ...
1 vote
3 answers
976 views
How can I query, increment & decrement arbitrary-length integers encoded into a bit-array?
I'm in the process of implementing a counting Bloom filter. This data structure is defined as a bit-array and a "width" parameter, W. The bit array stores unsigned integers, whose size is determined ...
2 votes
3 answers
444 views
Why are CPUs' datapaths multiple of 8?
Current and common processing units are 8, 16, 32, 64, 128, etc bit. Why are their datapath multiple of 8 ? Is this all linked to the fact that the industry has settled with a 8-bit byte ? The PDP-7 ...
12 votes
6 answers
1k views
Is power-of-two bits per word "convenient"? If it is, why is that?
I find several sources claiming that power-of-two bits in a binary word (such as 8-bits per byte) is a "good thing" or "convenient". I find no source pointing out why. From What is the history of ...
3 votes
5 answers
869 views
Why isn't byte | bit the only built in data type?
All languages I have seen so far have multiple builtin data types (int, double, float, char, long...). But if we look closely, they are just arbitrary arrays of bits, the only difference between them ...
26 votes
8 answers
12k views
Advantages and disadvantages of using bit masks in database
Not so long ago I talked to my colleague and he was definitely against using bit masks because it is hard to understand all the values that are stored in the database. In my opinion it is not always a ...
4 votes
4 answers
7k views
Byte addressable vs bit addressable
Why are most computers byte addressable instead of bit addressable? By B/b addressable I mean that processor can operate on level of single B/b. Bit addressable advantages: Booleans have size of one ...