Questions tagged [bit]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
101 votes
7 answers
80k views

What is the history of why bytes are eight bits?

What were 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. But ...
DarenW's user avatar
  • 4,433
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 ...
user56reinstatemonica8's user avatar
42 votes
12 answers
6k 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 ...
Dokkat's user avatar
  • 567
26 votes
8 answers
11k 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 ...
Alex Ovechkin's user avatar
19 votes
4 answers
95k 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 ...
discussedtree's user avatar
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 ...
Andreas's user avatar
  • 299
7 votes
3 answers
4k 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 ...
Luke's user avatar
  • 273
5 votes
3 answers
2k 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 ...
Water's user avatar
  • 356
5 votes
1 answer
6k 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 ...
theharshest's user avatar
5 votes
1 answer
13k 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 ...
user3998276's user avatar
4 votes
3 answers
251 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 ...
Anon's user avatar
  • 3,593
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 ...
Ford O.'s user avatar
  • 223
4 votes
2 answers
2k 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 ...
user2296949's user avatar
3 votes
5 answers
767 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 ...
Ford O.'s user avatar
  • 223
3 votes
3 answers
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 ...
Shane Hsu's user avatar
  • 188
3 votes
2 answers
2k 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 ...
flashburn's user avatar
  • 147
2 votes
4 answers
14k 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, ...
dhblah's user avatar
  • 339
2 votes
6 answers
607 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 ...
Anon's user avatar
  • 3,593
2 votes
5 answers
1k 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::...
stackprotector's user avatar
2 votes
3 answers
373 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 ...
Benoît's user avatar
  • 129
1 vote
3 answers
420 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. ...
Cole Tobin's user avatar
  • 1,469
1 vote
2 answers
531 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 ...
Martin Perry's user avatar
1 vote
2 answers
104 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 ...
Lance's user avatar
  • 2,587
1 vote
3 answers
910 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 ...
Louis Thibault's user avatar
0 votes
2 answers
1k 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)...
Anon's user avatar
  • 3,593
0 votes
3 answers
2k 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, ...
mtraceur's user avatar
  • 239
0 votes
1 answer
586 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. ...
Aniket Thakur's user avatar
0 votes
4 answers
1k 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 ...
skyline's user avatar
  • 11
-2 votes
2 answers
579 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 ...
user128250's user avatar
-4 votes
3 answers
5k 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 ...
JPtheK9's user avatar
  • 199