Questions tagged [bit]

The tag has no usage guidance.

25 questions
Filter by
Sorted by
Tagged with
7answers
56k views

What is the history of why bytes are eight bits?

What where the historical forces at work, the tradeoffs to make, in deciding to use groups of eight bits as the fundamental unit ? There were machines, once upon a time, using other word sizes, ...
3answers
9k 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 ...
13answers
5k views

Is there an alternative to bits?

Is there an alternative to bits as the smallest unit of data? Something that won't be only 0 or 1, but actually hold many possible states in between? Wouldn't it be more natural to store floats like ...
7answers
6k 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 ...
3answers
63k views

How are negative signed values stored?

I was watching this video on the maximum and minimum values of signed integers. Take an example of a positive signed value - 0000 0001 The first bit denotes that the number is positive and the last ...
6answers
820 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 ...
1answer
2k views

Clearing the lowest set bit of a number

I can see in this tutorial on bit manipulation, under the heading "Extracting every last bit", that - Suppose we wish to find the lowest set bit of x (which is known to be non-zero). If we ...
3answers
1k views

Is a 'least significant bit' used anywhere practically today?

I'm working on a library that supports file reading, and right now I've always assumed that all the bytes are written in most significant bit first format. Is the least significant bit first format ...
3answers
2k views

How does word size affect the amount of virtual address space available?

So, I should really know this stuff already, but I am starting to learn more about the lower levels of software development. I am currently reading Computer Systems: A Programmer's Perspective. by ...
3answers
2k views

8 bit and 1 byte, is this a valid question to be asked?

I saw these question in our school's past paper, and I'm wondering if this is a valid question. How big is bool in C and C++? A) 1 bit B) 4 bit C) 8 bit D) 1 byte What is ...
2answers
1k views

Explanation to why Counting bits set, Brian Kernighan's way works

I found this link to count number of bits in a variable. I think it is pretty cool, but I can't figure out why it works. Can someone offer an explanation? Here is the code unsigned int v; // count ...
1answer
1k views

Endianness at bit level

I am learning the union and struct and I wrote the code below. What I do not understand is why the output is different when I change from a little endian to a big endian machine. My understanding is ...
5answers
634 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 ...
4answers
8k views

How to get from 1 byte to 2 bytes

We have 1 byte, which is 8 bits, which is 2^8. Now 2 bytes should be 2 * 1 byte, which is 2 * 2^8 = 2^9, but actually 2 bytes is 2^16. What am I missing here? It seems like 2 bytes isn't 2 * 1 byte, ...
4answers
3k 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 ...
2answers
141 views

Why are CPUs' datapaths mutiple 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 ...
3answers
399 views

How do I tell a user that bps means bits per second or bytes per second?

I'm writing an application that deals with the network and the hard drive. For the network portion, the application measures in bits per second, while the disk portion measures in bytes per second. ...
2answers
58 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 ...
3answers
541 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 ...
3answers
592 views

Bits - Least-Significant/Lowest is 0th or 1st; zero or one indexed

Question Is there a rough consensus if the bitmask 0x01 is properly said to have the "zeroth" bit set, or the "first" bit set? If there isn't rough consensus that there's a generally right answer, ...
1answer
349 views

Understanding bitmap logic

I was going though this blog and it says You can represent a list of distinct integers no larger than N using exactly N bits: if the integer i appears in your list, you set the i th bit to true. ...
2answers
68 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 ...
1answer
4k views

What is the difference between size and length? [closed]

It seems that the terms size and length are used interchangeably to describe how many bits, bytes or octets some data occupies, i.e. a length field in a data header is said to indicate the size of the ...
4answers
180 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 ...
3answers
2k views

Save flags in an int32 [closed]

Unity3d PlayerPrefs only allow saving certain types - string, float, and int32. Since int is composed of 32 bits, it should be able to store 32 flags or a bool[] of length 32. So far, I've thought ...