Questions tagged [bit]

A bit is a single binary digit.

Filter by
Sorted by
Tagged with
0 votes
0 answers
39 views

Why isn't an (intentional) overflow occuring in my python FizzBuzz implementation?

I noticed that two out of three of the values generally associated with FizzBuzz are one less than a value of 2n, and that made me want to try an implementation where it uses overflows instead of ...
NyanSequitur's user avatar
-1 votes
2 answers
47 views

How to add two large binary strings? Is there any inbuilt functions in java or do i have to do it manually? [duplicate]

https://leetcode.com/problems/add-binary/ I tried to convert the string into integers using String.parseInt(stringname,2) and add the numbers, then i tried to return Integer.toBinaryString(sum).but ...
Sai Krishna's user avatar
0 votes
1 answer
45 views

How can I convert byte to fixed size (size = 8) bitArray

I want Convert Byte to fixed size (size = 8) bit array Want Behavior: var bits = GetBits(0x00); // returned [0,0,0,0,0,0,0,0] bits = GetBits(0x01); // returned [1,0,0,0,0,0,0,0] bits = GetBits(0x0A);...
SoulSystem's user avatar
0 votes
1 answer
24 views

How to initialize a variable

I want to store in n a 32-bit integer number. How should I initialize the variable n? With unsigned int n or with int n? Can someone tell me the difference between these two ? The sign of the number ...
Didi's user avatar
  • 11
0 votes
0 answers
40 views

Why doesn't Base 64 decoding convert to bytes as expected?

Given the base 64 string A/== this decodes to 00000011. However, according to the Base 64 spec, A translates to binary 000000 and / translates to binary 111111. Together, this would be 000000111111, ...
Jawad's user avatar
  • 313
1 vote
2 answers
116 views

How does bitshifting to the left by 3 gives you the number of bits in bytes?

I'm learning about bit packing and bit buffers and I came across this line of code int NumBits = sizeof(float) << 3 now the output is correct, a float is 4 bytes and when you convert that to ...
noob-cryptor's user avatar
0 votes
1 answer
52 views

Rotating bits in a byte in Java

I am trying to implement right_encode found in the SHA 3 specifications. https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-185.pdf enter image description here The specific part I am ...
Pocket's user avatar
  • 3
1 vote
2 answers
91 views

Find the number of bits in the product of a multiplication without knowing one of the factors

Suppose I have some odd number N with more than 1000 bits and I want to multiply it by some number H so that their product results in a number in which all its bits are 1. For example: N = 0b1101 ...
user1240174's user avatar
1 vote
0 answers
52 views

Confused about the result using the reinterpret_cast in C++ [duplicate]

For experiment, I create an integer first. int num = 7; int* pold = &num; std::cout << pold << std::endl; // 0000005E3DBEF7B0 I am working on 64-bit MSVC and thus assume bit ...
user22691690's user avatar
0 votes
2 answers
110 views

Storing data not aligned to bytes without padding in Python (NumPy)

I have image data that is represented with 10 or 12-bit integers and I would like to save this data to disk without writing the unnecessary 6 or 4 zeros of padding when using 16-bit integer to ...
Daniel Konečný's user avatar
0 votes
2 answers
101 views

What is a byte value (Assembly)

I'm new to assembly programming, my first homework is to make a program that reads a byte value, and displays it back to the screen. My problem is, I'm not sure what they mean by byte value. I know ...
kur0bane's user avatar
2 votes
1 answer
65 views

Finding the log base 2 rounded up to integer the same as rounding up to power of two and finding the highest set bit?

Similarly, value rounded down to power of two and finding the rightmost set bit is equivalent to log base 2 rounded down to integer. Is that correct? I thought that that would work, for any number ...
Zebrafish's user avatar
  • 12.1k
0 votes
1 answer
60 views

'bit_ceil' was not declared in this scope

I am trying to use bit_ceil(), I included the <bit> header, and used the std namespace (I know that it is not a good practice, but I did it here for the sake of the question). But when I try to ...
Abdullah Kassar's user avatar
0 votes
4 answers
85 views

why is the hexadecimal value of a float typecasted into an integer different from the float's actual hexadecimal value

Why are the hexadecimal values printed by the program different from each other knowing that the binary representation of both -12.342 (float) and the value stored in bi is the same ? #include <...
Fallendo's user avatar
0 votes
0 answers
30 views

What would be the hexadecimal representation of the largest memory address in a memory consisting of 4MB if each cell had a one-byte capacity?

What would be the hexadecimal representation of the largest memory address in a memory consisting of 4MB if each cell had a one-byte capacity? Since 4MB is equal to 4*1,000,000 Bytes, can I assume ...
Ahmed ZEER's user avatar
-1 votes
2 answers
129 views

Exercise about counting 1 bits in an integer in C

Exercise 2-9. In a two's complement number system, x &= (x-1) deletes the rightmost 1-bit in x. Explain why. Use this observation to write a faster version of bitcount. The bitcount function ...
oabdullae's user avatar
3 votes
1 answer
60 views

Find the maximum k such that it's possible to get a string of 1s after applying the bitwise negation to the substrings of length >= k

You can choose a substring of length >= k unlimited times and apply the bitwise negation to it. The answer is the maximum k that allows to get a string of 1s from the initial string. Any ideas on ...
fragrantmonk's user avatar
0 votes
1 answer
74 views

how do i convert a normal int to a 12bit long binary code, to then convert it to 2 letters with Base64?

I have multiple positive integers, which all hold numbers that can be represented by 12 bits or less. I need to convert each value of each integer to a 12 bit binary code, and then split each 12 bit ...
Daveik's user avatar
  • 1
0 votes
0 answers
48 views

Dislocker error: "EOW information at offset 4b22000 failed to pass the tests"

I am trying to mount a BitLocker encrypted drive using Dislocker, but I am getting the following error: Wed Aug 30 21:02:19 2023 [ERROR] EOW information at offset 4b22000 failed to pass the tests Wed ...
vishal Arekar's user avatar
1 vote
1 answer
106 views

How to create an octet type similar to std::byte in C++?

The type std::byte comprises CHAR_BIT bits, and that may be more than 8. So, how do I declare a true octet in C++?
wimalopaan's user avatar
  • 5,060
0 votes
1 answer
70 views

Unusual Behavior: Tailwind CSS Integration with Bit.dev Components in React Project

I'm currently experiencing an issue with integrating Bit.dev components that utilize Tailwind CSS into my React project. Despite diligently following the steps outlined in the Bit.dev blog, I'm ...
Aliansyah Firdaus's user avatar
0 votes
1 answer
125 views

Reverse a 32 bit integer in java

I am solving the question on reversing the bits of a 32 Bit Integer in Java and below is the code for the same: public class Solution { public static long reverseBits(long n) { int f=31; ...
Lakshya Gupta's user avatar
-2 votes
1 answer
60 views

Modify frame rate and bit rate with swift

I am recording video with a camera that returns .mov format then I export that video in .mp4 format and change the Quality to reduce the size of the video with the following code... func ...
Wahab Khan Jadon's user avatar
0 votes
0 answers
106 views

Read bits from double in HLSL

I am trying to convert a bits library of mine from C# to HLSL, but I am unable to convert 2 functions that use bitwise operators on doubles static public int getBits(int start, int end, long value)...
Bloxxy 213's user avatar
0 votes
0 answers
15 views

How I lock my drive through bit locker, If bitlocker is sending me error while locking drive

Here is the error image How I solve this issue in my pc?
Saad ZIauddin's user avatar
0 votes
0 answers
51 views

debezium Postgres bit varying field

I'm having trouble converting data coming out of debezium (postgres) on a bit varying(36) column. Example inputs and outputs are provided below. Documentation says (under "basic types" ...
Andy F.'s user avatar
  • 11
0 votes
0 answers
54 views

How to efficiently calculate the decimal value from the first 29 bits of the fractional part (of an CoolFlux BSP32 accumulator)?

I am trying to write a C (with CoolFlux BSP32) program which takes as input an accumulator and displays its decimal value. For example for an acc with the value in hexadecimal FF C000 0000, I want to ...
User's user avatar
  • 1
2 votes
1 answer
42 views

Value changing when assigned to variable

I am writting a programm to decode a binary file. I am currently in test phase and I use phpunit. I tried to assign a two byte value into a variable but the value changed without any apparent reason. ...
Jean-Rémi Lapierre's user avatar
1 vote
2 answers
269 views

Bit Array in Codesys

I can assign different values to a bit variable with the array of bit structure in C. On the Codesys side, I am not allowed to define an array of bits in the structures. Is there a solution you can ...
Ars's user avatar
  • 11
0 votes
0 answers
55 views

Can I write values to memory bit by bit? [duplicate]

From my research this afternoon, it doesn't seem readily possible. What I have going on is an array with 9 elements, each element is one byte in length. However, each of those bytes is subdivided into ...
James Long's user avatar
0 votes
0 answers
11 views

Why use XGbytes address space for a DRAM controller

#1. Does "64GByte address space" means 64*(1024^3)8 of different addresses? #2. Or 64(1024^3) different addresses and each locations is 1 byte wide. According to the documentation that I am ...
Leo's user avatar
  • 97
0 votes
1 answer
87 views

Is it possible to declare a type with a set bit width in c++ without using a struct?

It's been at least a decade since I last touched C++. Supposedly, C++ has had a minor overhaul. Is there a way to specify the bit width of a type without using struct, class, or union bitfields? The ...
ATL_DEV's user avatar
  • 9,362
0 votes
0 answers
92 views

How can I quickly iterate over bits in a binary file in python?

I would like to quickly iterate over bits in a binary file using python3. I need to read all bytes and convert all bytes to bits and apply a shift register for each bit. As soon as the shift register ...
Example UserName's user avatar
0 votes
0 answers
106 views

Bits visualization using Qt

I'm writing a program that can display file in bit view. Bits are visualized as filled and empty circles. Orogram allows to group bits by period, select bits, highlight columns and rows etc. I'm using ...
rooltex's user avatar
  • 134
-2 votes
1 answer
213 views

Parse bit-packed numbers from hex string in Python

I am unfamiliar with struct.pack() and unpack(). I have a string '08d16113' representing a 4 byte sequence. I need to: Convert it to a 32 bit number. Convert the number to 2 decimal integers, such ...
Adrian Doss's user avatar
2 votes
3 answers
89 views

what happens if we compare unsigned short int and unsigned char (comparing the bits)? (in C language)

For example: unsigned char mask1 = 0x55; //01010101 unsigned short int mask2 = 0x8055;//1000000001010101 unsigned short int res = 0; //0000000000000000 res = mask1 | mask2; so what ...
Pentakorr's user avatar
0 votes
0 answers
30 views

How to use an array that stores one byte in the fread function(In Triple_DES Algorithm)

I am trying to use the fread function. In the code below, input_text stores values ​​in bit units, but file_size represents the number of bytes. Because of this, wrong values ​​are entered in the ...
이동현's user avatar
0 votes
1 answer
38 views

1 bit comaparator using 2x1 mux ? Create First 1 bit magnitude comparator and implement on mux?

I know What is the comparator but i don't know how to implement with Mux Please Give Answer Of Hoe to Design 1 bit comaparator using 2x1 mux, I Create First 1 bit magnitude comparator in this we have ...
Meet Bhatt's user avatar
0 votes
1 answer
110 views

integer flags in system function calls

Here is an example for what I mean: int open(const char *pathname, int flags); and from the man page. Looking into Linux, it is obvious the flags are bit markers. I am curious by the use of an int as ...
user129393192's user avatar
5 votes
5 answers
309 views

How to store a chess game efficiently?

What's the most space efficient way to store an entire chess game in a database? considering an avg game length of 50-70 moves (1 move means 2 player moves once), i hope it takes less than 800 bits. ...
Coder shoder's user avatar
0 votes
2 answers
23 views

Expression Typed Incorrectly or Expression too Complicated?

Trying to run a rather simple query to fill a report in MS Access but its kicking back this error. It is supposed to select all records where MRC is TRUE between these 2 dates. It works just fine when ...
Luna8426's user avatar
0 votes
1 answer
65 views

My program reads my file, coded using huffman encoding wrong! Most of the bytes end up being '11111101', even though they're not. Why is that?

Im currently working on my huffman decoder in java. I've been stuck on wrong decoding for few days now, and only yesterday I realised it's bacause my program reads input wrong! I've downloaded outside ...
witw2's user avatar
  • 3
0 votes
0 answers
29 views

How to get the tag number in BER-TLV?

I have such a question, let's say the tag consists of 2 bytes 10011111 01110110 In training articles or videos, they say that in this case the B5-B1 bits in the first byte and B1-B7 of the second byte ...
lbsmart's user avatar
  • 75
1 vote
1 answer
58 views

How to initialize a buffer of large size to all bits on?

I am trying to initialize a bitmap to all bits on. My idea was to initialize an array of the buffer size and then use memcpy; however: #include <stdio.h> #define SIZE 5 int main () { int i[...
user129393192's user avatar
2 votes
2 answers
130 views

Jump values of N bits set?

I want the next + 100,000 value of a number with N bits, given that the resulting value must have N bits as well. So, for example : 30 is 0b11110 and the next value is 39 0b100111; I read that links ...
LeXav's user avatar
  • 123
1 vote
4 answers
101 views

Java BitSet.size() is not returning the size I gave at the constructor

I have the following code: private BitSet arrayListToBitSet(ArrayList<Boolean> code) { // The problem is here, the bitset automatically is created using 64 bits even tho we are ...
Laughcheeta1's user avatar
0 votes
1 answer
30 views

how do you use bit swift in python

import sympy as sp import sys import datetime import decimal start_time = datetime.datetime.now() x = sp.symbols('x') a = 1234123412341234 f_x = 1/x - a fp_x = sp.diff(f_x) # 미분 x_init = sys....
kimking's user avatar
0 votes
0 answers
90 views

How to find the maximum saving in bits that could be made by using Run-Length encoding to an image of a particular resolution?

So I'm currently looking at run-length encoding and I understand how the concept works and I can apply it directly to images and such. For instance, I was looking at this question: Data representing ...
Mighty Funkster's user avatar
0 votes
0 answers
196 views

How is a boolean (1-bit) stored in the memory? [duplicate]

When the lowest possible allocable in memory is 1 byte, how is a boolean stored in memory? If C++ uses 1 byte for each boolean, why don't use the 7 empty bits for other booleans?
Jibel's user avatar
  • 127
-2 votes
1 answer
251 views

How to reinterpret bits of float as int in python

I had to write code that printed out bits of floating point number (in hexadecimal). For C++, the first thing that came to mind was std::cout << std::hex << *reinterpret_cast<uint32_t*&...
God I Am Clown's user avatar

1
2 3 4 5
72