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

Update a bit type column using case statement returns null

Here is my question (below will be the answer) I had a need to update a bit column based on the entry of another column in another table on another database. So my table structure looked like: DB1.Table1 ( field1 int IDENTITY (1,1) PRIMARY…
1
vote
1 answer

Bits tricks and magic

I'm writing a program in C++, and it has to be as minimal as possible. I need some help with an if/else statement. This is the code: if (lines & 1 << ((d & 1) * 30 + 5 * l + c)) { cout << "Invalid"; } else { lines |= 1 << ((d & 1) * 30 + 5…
aleeN1
  • 43
  • 8
1
vote
1 answer

In Python, how can I convert a RGB array to binary and get the most significant bit?

Im using scipy to read a image and extract the RGB array like this img_b = misc.imread('google.png') img_b_blue = img_b[:, :, 0] img_b_blue = img_b_blue.ravel() Now I need to convert the img_b_blue array to binary and get the most significant…
1
vote
2 answers

Python base64.b64encode. How to obtain the 6 bit value for each encoded character?

For example, say I perform base64.b64encode('Monday') to obtain 'TW9uZGF5'. But when I want to access the 6 bits for each of the characters, I get something like this (the ASCII values for each of these characters): [84 87 57 117 90 71 70…
okstef
  • 11
  • 4
1
vote
1 answer

Manipulations with bits

I have binary file that is represented in hexa e.g 4d42 b666 000a 0000 0000 0036 0000 0028 The first 4 bytes represent value which i want to extract. I know i can extract it right std::ifstream is("img.bmp", std::ifstream::binary); uint64_t data =…
Darlyn
  • 4,715
  • 12
  • 40
  • 90
1
vote
1 answer

Bitwise operation with difference in order of comparison - (0 to 1) vs (1 to 0)

I have a problem in which there are two sets of bits being compared. The first is the initial state, and the second is the new state. Initial State 1010 New State 1100 I want to bitwise compare these bitsets and generate a third bitset which…
1
vote
1 answer

How to check for a value on two bitmaps?

I have two bit maps and I need to check if a value is in one of them. Do I need to check on both, or can I add them and do the check once?
ruipacheco
  • 15,025
  • 19
  • 82
  • 138
1
vote
1 answer

In Python, how do I generate all permutations of a string of 0s and 1s in order?

I am trying to permutate a string of 0s and 1s of an arbitrary length. I've seen a lot of answers on this topic that do it so that the outcome for a string of length n will be like this for n=3. 000 001 010 011 100 101 110 111 But this is not what…
Perm. Questiin
  • 429
  • 2
  • 9
  • 21
1
vote
1 answer

How many Int32 numbers can be represented when N number of bits is set?

What I want to know is how many numbers can be set if N bits are set to 1 out of 32bits. Example lets try with 4 bits //HowMany(1) = 4 //1000 //0100 //0010 //0001 // //HowMany(2) = 6 //1001 //1010 //1100 //0110 //0101 //0011 public int HowMany(int…
MajorInc
  • 342
  • 3
  • 12
1
vote
1 answer

Bits Manipulation MiPS Assembly

The program takes a user input key, extracts the rightmost 5 bits from that key, then replaces those bits in between bits 2 to 6. This is what I've tried. lw $s1, 0($s0) # extracts the first word in the array beq $s1, $zero, done …
user7700613
1
vote
1 answer

Is there a possibility to create a memory-efficient sequence of bits in the JVM?

I've got a piece of code that takes into account a given amount of features, where each feature is Boolean. I'm looking for the most efficient way to store a set of such features. My initial thought was to try and store these as a BitSet. But then,…
shakedzy
  • 2,853
  • 5
  • 32
  • 62
1
vote
1 answer

How to check if two signed 32 bit integers cause overflow in MIPS?

I have figured out that for two unsigned integers, I can just do this: sll $a0, $a0, 31 #a0 is integer 1 to be added sll $a1, $a1, 31 #a1 is integer 2 add $t0, $a0, $a1 #result in $t0 addi $t1, $0, 2 beq $v0, $t0,…
mamajava
  • 75
  • 1
  • 7
1
vote
2 answers

C - How is arithmetic conversions made on memory level?

Say that I am comparing an int and a short int. According to the second edition of "The C Programming Language" written on page 173 the short int will be converted into an int, which is 4 bytes instead of the short integers 2 bytes on my system. My…
Donkey King
  • 87
  • 1
  • 8
1
vote
3 answers

calculation of bits needed

I need help with this I was asked that for an unsigned integer range 1 to 1 billion, ,how many bits are needed! How do we calculate this? Thank you UPDATE!!!! This what I wanted to know because the interviwer said 17
daydreamer
  • 87,243
  • 191
  • 450
  • 722
1
vote
1 answer

stuck while learning bit banging

This is my first question as I am new to coding. Well, I am trying to use a MCP digipot in SPI. As I am using a PIC16, writing in C, I learned that the XC8 library couldn't be included in a PIC16 project... So I thought I would learn a lot doing it…
Ted Hook
  • 11
  • 1