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

7-bit circular buffer with bit option flag in a byte

I'm hoping someone can help me on this. I made a function for an 8051 microcontroller that accepts input from a button and I'm using a cyclic buffer of 8 bits to store key states so I can make debouncing not an issue. The code to store data in the…
Mike -- No longer here
  • 2,064
  • 1
  • 15
  • 37
1
vote
2 answers

Search binary number

I have defined some values, see below, and I can`t use them properly. #define add 000001 #define sub 000010 #define jmp 000111 #define IMM 10000 #define ADDR 10001 In my code, I set an address in hex. parameter1 = false; …
Flave
  • 77
  • 1
  • 10
1
vote
0 answers

sql bit allow null ef4

I have in my database the following table table questions question_id int answer bit nullble question string
maggie
  • 193
  • 16
1
vote
1 answer

How to fix bugs in my i2c bit bang python library?

I have a problem with my i2c library on raspberry pi zero. I have written my code in python using many tutorials but none of them was fully sufficient. In this code time.sleep() is missing, but even when included, problem still exists. It can…
1
vote
1 answer

MicroPython ESP8266 SPI interface sends wrong data

A very basic circuit uses MicroPython and the SPI interface to connect an ESP8266 MCU to a 74HC595 shift register. This is how I try to send the data: from machine import Pin, SPI hspi = SPI(-1, baudrate=50000, polarity=0, phase=0, sck=Pin(14),…
nagylzs
  • 3,954
  • 6
  • 39
  • 70
1
vote
1 answer

Parity Lookup Table generation

I was reading bit twiddling hacks for computing parity from this link: Bit Twiddling Hacks For computing parity, there is a lookup method, which generates parity table for integers from 0 to 255 with 5 codes of line. #define P2(n) n, n ^ 1, n ^ 1,…
aroup
  • 315
  • 3
  • 13
1
vote
1 answer

Count changing bits in numpy array

I'm doing my first steps with Python3, so I'm not sure how to solve the following task. I'd like to count how often each bit in a numpy array changes over the time, my array looks like this: first column: timestamp; second column: ID; third to last…
D. Scharf
  • 13
  • 4
1
vote
1 answer

Getting bits from Javascript Uint8ClampedArray

I have a node server running, and in the server I generate and store into Redis a bunch of bits representing colours on a canvas. Every four bits of the stored bits represents a 4 bit colour. (Ex. If I store 001001101011111, then the colours I'm…
1
vote
0 answers

64-bit double on 32-bit computer

I have an 32-bit int 0x31333337 and a 64-bit double 0x40786B6364333435. I am asked how they will be represented on 32-bit computer with little endian representation. The first is obvious: 37 | 33 | 33 | 31 But the second one is not. I think that…
stackoverload
  • 119
  • 1
  • 6
1
vote
3 answers

Randomly initialize BitSet with specific length

I have two BitSets which have to be initialized randomly with the length of 20 bits. I am trying to achieve that by initializing the BitSets with 20 bits each and within a for loop iterating through the BitSets and call nextBoolean() of the Random…
Bab
  • 433
  • 5
  • 12
1
vote
1 answer

find the value of given bit in javascript

I have a test which I don't understand what I have to do maybe because I didn't work a lot with bits. the test is this: it('you should be able to find the value of a given bit', function() { expect(answers.valueAtBit(128, 8)).to.eql(1); …
1
vote
2 answers

Why does my conversion of four bytes to binary have only 30 binary digits?

I have an IP address R (ie: "255.255.255.0") in string form that I'm hashing, and taking the first 4 bytes of that hash. I want to then convert that hashed result to binary format: def H(R): h = hashlib.sha256(R.encode('utf-8')) return…
user1045890
  • 379
  • 1
  • 5
  • 11
1
vote
1 answer

What's the best way to check the state of a certain bit, in a 32-bit word architecture?

In a university lab, we are using a TI6713 processor for signal processing purposes. I have often found myself in a position where I need to do an action based on a flag bit located in one of the 32-bit registers. Some of these flags trigger…
VlassisFo
  • 650
  • 1
  • 8
  • 26
1
vote
2 answers

F# bit reversal permutation

I am trying to do a bit reversal permutation in F#. https://en.wikipedia.org/wiki/Bit-reversal_permutation I know how to do this in Python: def bitrev(x, bits): y = 0 for i in range(bits): y = (y << 1) | (x & 1) x >>= 1 …
normal chemist
  • 403
  • 1
  • 4
  • 11
1
vote
2 answers

Java convert unsigned big integer to unsigned byte

How to convert unsigned BigInteger into unsigned byte when the value is higher? String value = "202"; BigInteger a = new BigInteger( value ); Byte b = new BigInteger( value ).byteValue() // returns -54 How to get unsigned byte value from…
Pratap A.K
  • 4,337
  • 11
  • 42
  • 79