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

Convert UIColor to 24 bit value

I have a bluetooth device (led light) to which I can send different commands to. By now everything works fine and all the commands work. Now I want to send a custom command. The documentation says the following: [0X99] + [24 bit colorimetric value…
Patricks
  • 715
  • 2
  • 12
  • 25
1
vote
1 answer

Bit Flipping - How is the answer -61?

I am following this tutorial: https://www.tutorialspoint.com/cprogramming/c_bitwise_operators.htm https://www.tutorialspoint.com/cprogramming/c_operators.htm I am confused how A which starts out as: A = 0011 1100 (60 in decimal) can become -61 when…
user3808269
  • 1,321
  • 3
  • 21
  • 40
1
vote
1 answer

Converting Java code with Bit operation from Java to JavaScript code

I am re-writing a Java Code to Java Script and i got into this Bit operation that doesn't work the same, here is the original Java Code: ByteArrayOutputStream bos = new ByteArrayOutputStream(); bos.reset(); short x = 451; bos.write(x & 0xFF); byte[]…
user1322801
  • 839
  • 1
  • 12
  • 27
1
vote
1 answer

Explain the number of bits in a hash value that features both numbers and letters

I need some help understanding this concept: If I have a 256-bit hash, the value is essentially a 64-character long string. This is because each character is 4-bits long (64*4 = 256), correct? However, along with numbers letters are also used in…
Liv
  • 57
  • 7
1
vote
1 answer

hamming code parity distribution issue

Can someone please clarify where im going wrong. I'm at this 2 hours... I know that the first parity in the code includes itself and skips every first number after it in a yes and no sequence. the second skips every second set of numbers after…
Ravnica
  • 25
  • 4
1
vote
3 answers

Why MSB's are discarded during 2's complement multiplication?

I have a trouble with understanding why we discard MSB when we do multiplication of 2's complements numbers. Let's take 101 (decimal: -3) and 011 (decimal: 3) for example. Algorithm goes like this: first we double length of our numbers, then we do…
popfalushi
  • 1,332
  • 9
  • 15
1
vote
3 answers

Error while flipping bits

I was solving a challenge from HackerRank, it's called Flipping Bits From here: https://www.hackerrank.com/challenges/flipping-bits As I see every case that I have tried is correct You first input the number of numbers you want to convert. Then…
1
vote
0 answers

Read 8 bits each time from a text file in Java

So I already have a class that will read 8 bits from a file each time when I call the method read(). All the characters' corresponding decimal number is in ASCII table. Now I encountered a character 'É' whose ASCII code binary code is 11001001. And…
edhu
  • 449
  • 6
  • 23
1
vote
2 answers

Jooq Postgres Varying Bit

I am looking into Jooq and has struck something that I can find very little documentation for - none that really answers my question in all honesty. What I want to do is to have a column in a table like permissions varying bit(2000) (Postgres…
user1210708
  • 513
  • 4
  • 11
1
vote
1 answer

Machine Language Instruction on C++ Tutorial

I started learning C++ on the website cplusplus.com and there is a tutorial about the language. In that tutorial the first lesson is on compilers and in that lesson, that can be found at http://www.cplusplus.com/doc/tutorial/introduction/, they give…
SineLaboreNihil
  • 953
  • 4
  • 11
  • 18
1
vote
1 answer

boost::multiprecision::export_bits lose sign when exporting cpp_int type to bits

I export negative sign value to bits and import back, but when bits impotring sign has lost. typedef multiprecision::int512_t balance_value; vector byteSet; export_bits(static_cast(balance),…
Denis Makovsky
  • 460
  • 7
  • 22
1
vote
1 answer

swap bit i and j of an integer

Given an integer, swap the i-th and j-th bit. I have tried solving this question myself. Do you guys think it is too "wordy" (long)? int swap_bit(int num, int i, int j){ int a=(num>>i) & 1; //i-th bit int b=(num>>j) & 1; //j-th bit int…
Anni_housie
  • 489
  • 1
  • 6
  • 12
1
vote
1 answer

ALU design error

I want to design an 8 bit alu in VHDL but I get this errors, I think it has something to do with the fact that my inputs are declared as bit_vectors. Is that true? ** Error: C:/Programs/Modeltech_pe_edu_10.4a/examples/alu.vhdl(19): No feasible…
blaa
  • 801
  • 3
  • 16
  • 32
1
vote
1 answer

Mips assembly language loop through array and isolates bits of interest

I need to loop through this array of bytes testCases: .byte 0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47 Im assuming I would do something like this, but not sure ori $a1, $0, 0x0 # Initialize index with 0 LOOP: …
1
vote
3 answers

Performing a logical not ! using only bitwise operations

Possible Duplicate: Check if a number is non zero using bitwise operators in C. Hello everyone, I am working on a project and I need a little help with a function. We need to write a function that performs the logical not, !, using only the…
NotAround
  • 11
  • 1
  • 2