Questions tagged [bit]

A bit is a single binary digit.

A bit refers to a single binary digit, the smallest possible amount of information. In print is usually represented as either 0 or 1, with many different representations in technology, like the presence or absence of an electric current or magnetic field.

Eight bits form a single , although historically the term has been used for other sizes as well.

3593 questions
1
vote
1 answer

Putting a 5-bit value to a byte in VHDL - Will this generate a latch?

I have the following problem: I have an adder whose output has 5 bits. I want to send this output to an 8-bit register. I've declared the register input signal as tot_sig, and the adder output as add_out. Both the register and the adder are…
embedded_dev
  • 195
  • 9
1
vote
2 answers

How can I generate a 256 bit mask

I have an array of uint64_t[4], and I need to generate a mask, such that the array, if it were a 256-bit integer, equals (1 << w) - 1, where w goes from 1 to 256. The best thing I have come up with is branchless, but it takes MANY instructions. It…
Shawn Landden
  • 73
  • 1
  • 8
1
vote
0 answers

How to cast a bit sequence of arbitrary length to a signed or unsigned integer in Python?

I need to cast bit sequences of arbitrary length to signed or unsigned integers. Those sequences are represented as strings. for example, I have to cast '001100100110100101110011001010' to an unsigned integer and '10000000' to a signed integer. I…
Pim Klaassen
  • 95
  • 1
  • 7
1
vote
1 answer

Accessing the bits in char through a bitfield

I want to access the bits in a char individually. There are several questions and answers on this topic here on SO, but they all suggest to use boolean mathematics. However, for my use it would be more convenient if I could simply name the bits…
Henri Menke
  • 10,705
  • 1
  • 24
  • 42
1
vote
1 answer

How to convert each char in string to 8 bit int? JAVA

I've been suggested a TCP-like checksum, which consists of the sum of the (integer) sequence and ack field values, added to a character-by-character sum of the payload field of the packet (i.e., treat each character as if it were an 8 bit integer…
bemzoo
  • 172
  • 14
1
vote
1 answer

How to extract the bit field from pixels

I have an image from a satellite with pixels values between 0 and 255. This image contains several tests of information No/Yes (0/1) storage in a 48-bit product. I need to get the information for a test in a pixel; specifically, I need to get the…
1
vote
2 answers

Float array to bytes converts as null

I am trying to continuously send array of 6 floats over MQTT protocol. I was sending them as ASCII characters using sprintf function. I decided to send them as raw bytes. I put these floats into a union to represent them as unsigned char. The…
Şener
  • 25
  • 4
1
vote
1 answer

Get a value in a function with bit manipulation

In a particular graphic library one represents pixels with 32-bit values consisting of four bytes for representing the four components RED, GREEN, BLUE and Alpha. The following definitions are available: typedef unsigned int Uint32; typedef unsigned…
thpthp
  • 93
  • 1
  • 3
1
vote
2 answers

PHP base_convert() function doesn't work over 6 byte

I'm programming a web app where you put a hex value in a field and the app give you the details of which bit are up. But I'm facing a problem if a do: base_convert(value,16,2) with a 6 byte value I get the right bit correspondence, but if I do it…
1
vote
2 answers

why does the byte with bits 01110011 not become the character `s`?

Why does the following program not print an s character?: #include #include int main(void) { unsigned char s = '\0'; unsigned int bits[8] = {0, 1, 1, 1, 0, 0, 1, 1}; for (int i = 0; i < 8; i++) { s ^=…
Sebastian Karlsson
  • 715
  • 1
  • 8
  • 19
1
vote
2 answers

Bits needed to represent image-to-category mapping

You want to map every possible image of size 64 x 64 to a binary category (cat or non-cat). Each image has 3 channels and each pixel in each channel can take an integer value between (and including) 0 and 255. Source:…
canadair
  • 49
  • 1
  • 4
1
vote
2 answers

Discriminate bits after "bit stuffing"

I have written a piece of code to add a '0' after 6 consecutive '1' in a bit stream. But how to decode it? Here an example of one bits stream: original = {01101111110111000101111110001100...etc...} stuffed =…
user11043025
1
vote
1 answer

What does "1200 dpi at 1 bit" mean? Save plot with ggsave in R at 1 bit

I have a question about image resolution, as it's not an area with which I'm particularly familiar. I'm saving a black and white (actually, grayscale) plot I created with ggplot() (ggplot2 package) in R using ggsave(). According to a journal's…
Meg
  • 696
  • 1
  • 7
  • 20
1
vote
1 answer

How to print a decimal into a 32 binary separating it 8 bits

I am trying to print a 32 binary integer with 8 bits separated by a space. ex (00000000 00000000) Then the result should be used for future testing which I will integrate 512 for example as y. #define CHAR_BITS 8 void displayBits(unsigned int…
Vlad Ezikon
  • 93
  • 2
  • 11
1
vote
9 answers

Calculate how many ones in bits and bits inverting

Possible Duplicate: How many 1s in an n-bit integer? Hello How to calculate how many ones in bits? 1100110 -> 4 101 -> 2 And second question: How to invert bits? 1100110 -> 0011001 101 -> 010 Thanks
VextoR
  • 5,087
  • 22
  • 74
  • 109