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
3 answers

How can i encode and decode two number in a single integer using bit manipulations?

I was learning about bit manipulations then I thought of this. Say I have two numbers, First in the range of [1,6] and second in the range of [0,3]. Now the first number can take max 3 bits to be stored and the second can take 2 bits to be stored.…
1
vote
1 answer

Bit-level querying in Hadoop and Hive

We have a use case for bit-level querying in Hadoop. It goes something like this: Given a set of variable-length records containing a date/time stamp and one or more sixteen bit data words, return a list of date/time stamps where some combination…
Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
1
vote
4 answers

Unset All Bits Except Most Significant Bit C#

Is there a quick and easy way to unset all the bits in a number except the most significant bit? In other words I would like to take an integer x and apply & operator to it where the operand is 1 left-shifted by total number of bits in x. Example:…
rpetrk
  • 25
  • 7
1
vote
1 answer

Convert binary numbers to byte with a GNU Core Utility?

How do I convert the string 01100110 01101111 01101111 to foo in Unix? Which of the GNU Core Utilities does that if any? I know how to do it in Python, but it must be possible with another tool, no? The tools hexdump and od don't seem to do the…
tommy.carstensen
  • 8,962
  • 15
  • 65
  • 108
1
vote
1 answer

C# BitArray with leading zeros

I've tried something like this: BitArray bits = new BitArray(00001110); But the result is 1110 It seems like the BitArray cut the leading zeros. Is it possible to create a BitArray with the leading zeros?
PMe
  • 545
  • 2
  • 9
  • 20
1
vote
3 answers

Bit shift in array and write score to another array

I write method to bit shift by one in array and save to second array. Let me explain on below example: unsigned int firstNumber[2] = { 0x00000001, 0x8FFFFFFF }; unsigned int resultNumber[2]; And result should be: unsigned int resultNumber[2] =…
xLukasbx
  • 35
  • 4
1
vote
1 answer

Most significant bit in 2 bytes

I have got the number 317 saved in 2 bytes (00000001 00111101) and it should be transfered via SPI (serial) to a slave device. The device expect the two bytes B11 and B12, but in a certain order: "The highest bits of the data words are send first…
Lexinas
  • 27
  • 2
1
vote
2 answers

how to access UNKNOWN in sql server's boolean?

Hi I learned sql server's BIT has true, false, and unknown. For example, the comparison 1 > NULL yields unknown. I know I can check it indirectly: if x is null or y is null, then the comparison x > y must be unknown. Is there a way to access unknown…
YJZ
  • 3,934
  • 11
  • 43
  • 67
1
vote
0 answers

Predicting next bit in a non random sequence

I have a nonrandom sequence of bits - I'm able to tell that the sequence is nonrandom because I have performed on it the runs test, moreover the sequence presents autocorrelation at lag 1 equal to 0.4 (right before the cutoff) whereas the partial…
james42
  • 307
  • 5
  • 16
1
vote
1 answer

Data alignment and zero-bits relation?

Reading through a paper for the ARM Cortex-M3 CPU I found this line confusing: The lowest 2 bits of the stack pointers are always 0, which means they are always word aligned I have seen similar statements elsewhere. What is the logic behind…
user1481860
1
vote
2 answers

C++- Reverse bits in hex

I want to be able to reverse the bits stored at a memory address (in hex). So for example, 0xABCD -> 0xDCBA I have looked at other solutions online and they all involve complex bit manipulation and I wanted to see if there was a way to do it using…
1
vote
2 answers

How to break an int into digits and assign digits to a vector in same order?

I am using a Constructor to take an unsigned int as an argument, break it into digits and assign the appropriate true and false values to a vector object. But the problem is that, my poor logic assigns the values in reverse order as the last digit…
HN Learner
  • 544
  • 7
  • 19
1
vote
0 answers

Reading Huffman tree and decoding a message

I'm trying to implement a Huffman compressor in С++. In brief I have 5 classes: HuffmanTree - represents a tree structure TreeNode - represents a tree structure HuffmanArchiver - compress/decompress etc. BitStringWrite - writing bits. BitStringRead…
False Promise
  • 478
  • 3
  • 6
  • 13
1
vote
2 answers

Check multiple bits in bitset

I got the following code: p = B[m] & B[m + 5] & B[m + 6] & B[m + 11]; m -= d * (l > 0) * 11 + !d * (c % 5 > 0); p += m ^ M ? B[m] & B[m + 5] & B[m + 6] & B[m + 11] : 0; I know it's hard to read, but here's a TL;DR for it : I check multiple bits…
aleeN1
  • 43
  • 8
1
vote
0 answers

Framing bits with matlab

Please How I can make framing process for data bits . Moreover, deframing with serializing the data. Finally, sending data to BSC BINARY symmetric channel.