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

How do I get nbit types from fread?

I have a file that is a concatenation of K, 17-bit, little endian, unsigned integers. In Matlab I am able to use fread(fd, K, 'bit17', 'ieee-le'). How do I read 17 bits off of a file descriptor in octave?
probinso
  • 309
  • 2
  • 9
1
vote
1 answer

Is the lost information by left shifting stored somewhere in Java?

So I was experimenting with left shifting in Java and I found something I didn't understand. The code below describes it. int x = -1 << 31; System.out.print(Integer.toBinaryString(-1) + " -1\n"); System.out.print(Integer.toBinaryString(x) + " " + x…
1
vote
0 answers

scanning multiple serial data bits reliably - 8051

My hardware currently has four sets of sensors that I treat as four separate serial ports with receive functionality only enabled wired to the lower 4 bits of port 0. I have attempted numerous times to retrieve the correct serial port data (by…
Mike -- No longer here
  • 2,064
  • 1
  • 15
  • 37
1
vote
3 answers

Reversal of a binary number using bit hacks

Can someone please explain how the binary number is being reversed. unsigned rev = 0; unsigned k = n; while (k) { // add rightmost bit to rev rev = (rev << 1) | (k & 1); k = k >> 1; // drop last bit cout<<"k val is…
Tanmay Jha
  • 11
  • 5
1
vote
0 answers

numpy integer array and bit masking

I have a numpy array storing integer values. These integer represent in single bit or groups of bits values that I need to test against some bit masks. For instance I need to extract for all values in the array the bits 2 and 3 (LSB) and test them…
1
vote
3 answers

Is it possible to compress a single byte without any loss?

I know it sounds kind of impossible, because 1 byte can represent 256 different values, but I still wonder if there's (even just theoretically) any approach to achieve that.
1
vote
1 answer

Write Bit in Buffer Nodejs

Friends how can I write a bit into Node js Buffer, I can write Byte, integers etc but do not know how to write bits. is it possible? if yes then how? I should write a bollean in buffer 1 or 0 and read it in API using readBit() thats why I need write…
1
vote
1 answer

How to read binary data into R with a bit depth of 24 readBin

I have a binary data file (containing audio data) with the extension .w. I opened a file connection using the following code in R; file1 <- file("filename.w", "rb") # opening a file connection to .w binary file and specifying 'rb', read…
springsun
  • 11
  • 1
1
vote
0 answers

How to Read a Binary String from Right to Left?

i'm having a code in which a String is consists of Binary Code i want to read it from Right to left. Can Someone Suggest me Better Way to Read the Binary String . string myString; using (FileStream fs = new FileStream("C:\\tvin.exe",…
AJAY KUMAR
  • 77
  • 7
1
vote
0 answers

How many bytes are typically held in a single memory address?

I understand that the answer to this question may significantly vary from system to system. But I would like to refine my understanding of how memory on a computer works. I understand that a memory address stores the location of a sequence of bits.…
user8768055
1
vote
1 answer

Reading data in verilog

Problem: I'm trying to manipulate 16 bit binary numbers in Verilog. The results I'm getting do not seem to match the expected results. I've isolated the problem in that the testbench.v seems to be sending the wrong values to my classify.v file. This…
john_log
  • 13
  • 4
1
vote
0 answers

C program to print all bits allocated for given variable, using Recursion

I was wondering what would a recursive function that prints all bits of the given variable (can be char, int, long, ...). Since char allocates 8 bits for a variable, I need to print a total of 8 bits. For example, if the input is 5, the function…
1
vote
2 answers

python bit_length() of 0 returns unexpected value

Why does the bit length of 0 return 0 and not 1? >>> int(0).bit_length() 0 >>> int(2).bit_length() 2 2 in binary is 0x10 which represents two bits, doesn't zero in binary still techincally take up 1 bit since its representation in hex is 0x0?
APorter1031
  • 2,107
  • 6
  • 17
  • 38
1
vote
3 answers

How To Cast a 4-Bit Char Array to an Int?

I'm coding a C program to read and parse a BMP header. The first 2 characters are chars, which I'm printing fine. However, all the other bits are ints in little endian format, so I'm storing them backwards. In hex, I'm getting the right answer.…
Donovan Jenkins
  • 133
  • 1
  • 13
1
vote
1 answer

How is it possible to have 0 bits per character?

I have an example of a string ABABABAB and I have to calculate an entropy of this string. It's obvious that i can get different numbers when taking different alphabets. When I took alphabet A={a,b} I got an answer for entropy = 1 bit per…
I K
  • 11
  • 2