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

Mask matches in bit manipulation

Here is a question related to bit manipulation(masks), I'm programming in Javascript. I want to do the following: const entityMask1 = new MaskManager(); entityMask1.addElement(0); entityMask1.addElement(1); entityMask1.addElement(2); let…
PerduGames
  • 1,108
  • 8
  • 19
1
vote
2 answers

How to slice off bits from an integer

I could create a bitwise trie that just looks like this: x _____________|___________ | | ___●___ ___□___ | | | | _■ _○ …
Lance
  • 75,200
  • 93
  • 289
  • 503
1
vote
2 answers

Representation of -1 due to bit overflow?

Hey I was trying to figure out why -1 << 4 (left) shift is FFF0 after looking and reading around web I came to know that "negative" numbers have a sign bit i.e 1. So just because "-1" would mean extra 1 bit ie (33) bits which isn't possible that's…
MasterKas
  • 87
  • 1
  • 7
1
vote
2 answers

Rendering bitstring from phoenix view

I have a bitstring of the form bitstring = <<18::6,8::4,2::5,16::5,18::6,3000::16,0::4>>. I want to render but poison or Jason doesn't seem to be rendering. What is the best way to render a bitstring in response like this. Something like this bits =…
Tanweer
  • 567
  • 1
  • 5
  • 17
1
vote
2 answers

Reading two 8 bit registers into 12 bit value of an ADXL362 in C

I'm querying an ADXL362 Digital Output MEMS Accelerometer for its axis data which it holds as two 8 bit registers which combine to give a 12 bit value and I'm trying to figure out how to combine those values. I've never been good at bitwise…
Reed H
  • 23
  • 3
1
vote
2 answers

How many bits are required to store the pointer value?

As far as I know, the size of the pointer on 32-bit systems is usually 4 bytes, and on 64-bit systems, 8 bytes. But as far as I know not all the bits are used to store the address. If so, is it safe to use free bits for other purposes? If so, how,…
Joe Joe
  • 121
  • 6
1
vote
1 answer

Haskell - Parse binary stream

I'm new to Haskell, so I'm probably missing something very simple. I'm having a supprisingly hard time trying to parse a structured binary stream. The binary stream has varying and conditional parts (like a field which determines how many items…
user1242770
1
vote
1 answer

How to flip the bit of 1 and 0 for prime indexes

I have a list of binary number and the bit need to be flipped from 0 to 1 or 1 to 0 for the prime index only. The list of binary number is actually near to 100 bit length. I have a code for example 8 bit long but it does not show the expected…
Afir
  • 483
  • 3
  • 15
1
vote
1 answer

How to make bit ignore a dependency file?

We have a current ReactJS project and we build a custom grid, input, error handler, etc for it. now we start a new project and we want to share our components code between projects. we do some research and find bit platform bitsrc.io so pleasant and…
javad bat
  • 4,236
  • 6
  • 26
  • 44
1
vote
1 answer

Unexpected value after shifting BigInteger to the left

I have a string which I'm converting to BigInteger by parsing then shifting it by 3 bits to the left and convert to a string again. The problem is that it always output extra bits before the actual value. For example: Private Sub…
James_BK
  • 21
  • 1
  • 7
1
vote
2 answers

Select a range of bits from bytes

[edit] Please close/delete, I was just counting from the wrong side. I'm working with this function with the hopes of extracting some number of bits from a starting position in a value. // Extract K bits from position P in the value int getBits(int…
Crizly
  • 971
  • 1
  • 12
  • 33
1
vote
1 answer

SQL Server - Bit data type matches String 'True' and 'False'

I'm not sure if something special has been done with the database that I am working with, but while optimizing old code, I came across the following (sanitized) query: SELECT Code FROM GovernmentThing WHERE IsGovernment = 'True' I checked the data…
Laughing Vergil
  • 3,706
  • 1
  • 14
  • 28
1
vote
1 answer

What's the exact meaning of the statement "Since ASCII used 7 bits for the character, it could only represent 128 different characters"?

I come across the below statement while studying about HTML Character Sets and Character Encoding : Since ASCII used 7 bits for the character, it could only represent 128 different characters. When we convert any decimal value from the ASCII…
user9059272
1
vote
1 answer

Why does one complex bits-shifting command not act like some commands with the same logic?

For example ,for these similar codes when I'm writing it like the first pattern the condition gets true and in the second pattern the condition gets false. I have watched the values of mask & (bits >> i) and mask in real-time in the debugger tool…
Oran Sherf
  • 39
  • 9
1
vote
1 answer

size of a field in an structure

Is there a way to get the size of a field in a structure? For instance, $bits does not work. any other approach? localparam L_DATA_BITS = $bits(pkt_char_t.length); typedef struct packed { logic [15:0] checksum; logic [3:0] …
Mike J
  • 11
  • 2