LaVOZs

The World’s Largest Online Community for Developers

'; Newest 'bit' Questions - LavOzs.Com

Questions tagged [bit]

A bit is a single binary digit.

• Creating addresses from multiple values in C

I am trying to create 32 bit addresses in C by combining multiple unsigned int values I have. These multiple values are important and need to be all stored into 1 32 bit address. For example: Say I ...
• Leetcode 191 - number of 1 bits - Easy Problem

Question: Write a function that takes an unsigned integer and return the number of '1' bits it has (also known as the Hamming weight). Example Input: 00000000000000000000000000001011. Output: 3 ...
• As the hamming weight is the number of non zero digits.. So how to write a code in C language to find hamming weight of 11101010101? [closed]

Hamming weight for a list of integers in Matlab i go through this link. But the language is not C
• How to write a single bit in a file in Java

I would like to know if it's possible to write in a file bit by bit. I have sevaral sequences of bits written as a String String bitString = "00101101"; // as an example for just one sequence And ...
• i want to transmit data by byte unit and i think it's metter about endianness

i want to transmit data by bit unit so i was access data with char* variable. here is my code. int main() { //initiate int variable and casting with char* int a = 65; cout << a <&...
• Merge ascii char using C [duplicate]

I tried the following code but couldn't get the desired output. Result should be AB and it should come from single variable C int main() { int a = 'A'; int b = 'B'; unsigned int C = a <<...
• How can I merge two ASCII characters? [closed]

I want to merge two characters and print them via a single variable by using ASCII (refer to the image below): [1]: https://i.stack.imgur.com/TWodP.jpg
• Using BitSet properly to replace int based flag. Is it possible?

I am getting an int from a data source that serves as a flag. Example: private static final int EMPLOYEE = 0x00000001; private static final int IT = 0x00000002; private static ...
• How does a computer recognizes the symbol '5' as being 101? [closed]

We all know that 5 in base 10 is represented as 101 in base 2. We also know that a computer stores this number in binary. However, one thing that I couldn't find online keeps bugging me. Down to the ...
• Broad Question - How do files know how much each value is and were they are positioned

For Example, So i was making a game, that stores thousands of values and i want to make the storing of those values (within a file) as efficient as possible. But so lets say that i attempt to store ...
• How to properly realloc a bit array in C

I'm trying to grow the array of bits dynamically as more values are entered. I'm having two issues so far. I gdb'd into it and I can't really see what part I'm missing while reallocing the bit array, ...
• bit wise counter on a single byte javascript

I want to use the bits valued at 2^4-2^8 in a Typed 16Uint array item to use as a binary counter to 16. 0000111100000000 ->15 0000111000000000 ->14 0000110100000000 ->13 ... 0000000000000000 ...
• Git BitBucket - When push fails and want to repush again, i am losing info of all scripts to be modified

I am new Git/Bit Bucket. I am using "git push" to push my code to repo. Sometimes the push fails due to incorrect JIRA number or name. So once i fix the problem, i want to do the push again. At that ...
• How do we manipulate the first bit of a u8 array in Rust? [duplicate]

I'm trying to make an asynchronous WebSocket server (my own implementation). I have the following code: use tokio::net::TcpListener; #[tokio::main] async fn main() -> Result<(), Box<dyn std:...
• bit manipulation BMP python3

I'm trying to retrieve a text I've hidden inside a BMP image but when I want to convert it to ASCII, I've got the following error: "UnicodeDecodeError: 'utf-8' codec can't decode byte 0x94 in position ...
• Unexpected behaviour using bit-fields and unions

I was experimenting with bit-fields and unions and created this: union REG{ struct{ char posX: 7; char posY: 7; unsigned char dir: 2; }; unsigned short reg; }; ...
• C# Converting pixel colour to binary

For use in a steganography program. I am trying to get the binary equivelant of the R value of a pixel from a bmp, ie: if R value is '255', I want '11111111'. I am going to loop through the binary ...
• Is there a standard way, pattern or idiom to work with bits (for streams, encoding, …)?

Recently I saw myself writing a method that would encode characters to bits (doing Huffman, but that's not relevant). Not bytes, but bits; groups of less than 8 bits. I wrote something like the ...

I am a newbie and a little bit lost and cannot find a solution. I Need to find a formula in Hex which says all 8 bit numbers that start with 1. I Need this to check if it is the first Byte of my laser....
• Integer.valueOf not working for binary representation of -1 in Java

The following code attempts to output to obtain -1 from its 2's complement binary representation, but gives a NumberFormatException. System.out.println(Integer.parseInt(Integer.toBinaryString(-1), 2))...
• How can I concatenate integer bit fields in c into a uint64_t integer?

I have a struct in c like this struct RegisterStruct { uint64_t b_0 : 64; uint64_t b_1 : 64; uint64_t c_0 : 64; uint64_t c_1 : 64; uint64_t c_2 : 64; uint64_t d_0 : 64; ...
• How can I concatenate 4 bytes to 8 in c++?

How can I concatenate 4 bytes to 8? Example: long var1 = 0x01011; //0001 0000 0001 0001 long var2 = 0x03034; //0011 0000 0011 0100 // MAGIC... long result = 0x10113034; //0001 0000 0001 0001 0011 ...
• how to determine if a 0 bit in one int goes to 1 in another int

Say you have two integers, A and B. int A = 0b0011; int B = 0b1001; How do I determine if a 0 in A goes to a 1 in B. I don't care if a 1 in A goes to 0 in B, or if the bit stays the same, only if a ...
• Reinstalling Jupyter for python version change

I have uninstalled python for win32 and reinstalled win64 version. But the jupyter notebook has problems with importing some library, while Pycharm works just fine. (Keeps saying "no module named ...
• How is size of characters in ascii table

I was confused and i have questions, the first one is how many bites in chars ASCII table, i have heard that any char from ASCII is 7 or 8 bits but let's take an example, char "1" is 110001 so its ...
• Inserting 1-32 bits into a 64 bit (8x8byte) buffer

I am trying to insert a value that is from 1 to 32 bits long into a buffer of 8 bytes (64 bits). For example, I have 12 bit value that I want to insert into bit position 7 through 18. The only way ...
• How do I share variables using the bit platform?

In my project they want me to share the environment variables that are in the nodeJs .env file, with other microservices. And they want the Bit platform to be used. Does anyone know if this is ...
• I want to upgrade by flutter version by I'm facing an error while updating dart sdk

Currently I'm using Windows 10 OS . I wanna start flutter as web app but i got hanged here . Please help me out .
• How do you check if your running in either 64 bit or 32 bit for Delphi Android 10.3.3?

Is there any documentation for Delphi Firemonkey Android 10.3.3 on checking to see if your running in either 32 bit or 64 bit on a Android device?? Answer from Dalija Prasnikar seems to work best: ...
• how do I extract the 5th bit of a byte in c#

If I have the decimal 12, its representation in binary is 00001100. How do I extract the fifth bit, which in this case is 1? I tried shifting left by 4 and AND-ing with 1 but this is not correct. Can ...
• Implementation of MD5 in Python

I was following a page on Wikipedia about the implementation of MD5. The pseudocode is directly embedded in the link. However, while I was translating the pseudocode into python, it gives a pretty ...
• Why Java isnt calculating logical shift right correctly?

I just learned about logical shift right. Why my java isnt calculating it correctly? Example: public class Operators { public static void main(String[] args) { byte z = -16; ...
• Why my code gives a different output when zero is added front?

can anyone explain why the output is 65? #include <stdio.h> int main() { int b=0101; printf("%d",b); return 0; }
• How can I convert string to bit then split it in half and do some function on a part and then xor it with the other then swap using java?

yeah it is simply feistel cipher.. I need to implement a simple program implementing it without using any preexisting code. I think that my main problem is in conversion of string to bit to do some ...
• small bitoperation problem with unsigned int in combination with unsigned char

Hi I got a small conceptual problem regarding bitoperations. See the below code where I have a 4byte unsigned int. Then I access the individual bytes by assigning the address's to unsigned chars. I ...
• Representing the state of a tic tac toe board using a bitset; how to efficiently find neighboring states?

I'm writing a state class that represents the state of a tic tac toe board. I want to find the neighboring states of the current state. The neighbors are basically the current state with the addition ...
• How to set all the bits in a char array to zeros?

I am creating a char pointer to an array and wanted to initilaize it so that all elements in the array have 0 (in bits). So for example: char* buffer = new char[bufferSize]; buffer[0] to buffer[...
• How to write byte(s) to a file in C++?

I have created a bitset using std::bitset<8> bits which is equivalent to 00000000 i.e., 1 byte. I have output file defined as std::ofstream outfile("./compressed", std::ofstream::out | std::...
• Array management in c [duplicate]

I'm having problem using pointers and arrays in C, the task is simple i have a function that converts digits into a int array then send back a pointer to this array. At this point i need to assign ...
• Bit shifting with enums

I have 4 properties and want to shift them in a byte called controlByte. The TypeEnum for example has 4 entries (0 = Unknown, 1 = Red, 2 = Blue, 3 = Green) Bit 0-1: TypeEnum Bit 2-3: SpeedEnum Bit 4: ...
• fast way to convert array of 16 bit unsigned interger to bits

I have a large dataset containing a 3d array of 16 bit unsigned integer. I want to convert each of the integer into bits and then only retain whose 8:12 bits are "0000" So far I am using a very slow ...
• Bit sizes of Fortran integers

I have the following program to give a minimal example I don't understand either about the bit representation in general or in Fortran. If I compile with gfortran 7.5 or ifort 18.0 it passes all ...
• How to pack the C bit field struct via encoding package in GO?

Except using cgo, Do you know what is the best way to pack the GO object to byte slice? We can use encoding/binary package to serialize GO struct to byte slice as far as we know but it supports only ...
• Bit-Operations on a character in ANSI C [duplicate]

Can anyone show me a good method to express a character in binary in C? I would need to see a given character as a sequence of 1 and 0. For example, if I get as an input 'a', I would like to see it as ...
• c bit manipulation (endianess)

Could someone explain me this code please ? I have received some byte code from an assembler and now I have to use it in my virtual machine. This code is used but I don't know how it works and what it ...
• Storing individual bits in memory

So I want to store random bits of length 1 to 8 (a BYTE) in memory. I know that computer aren't efficient enough to store individual bits in memory and that we must store at least a BYTE data on most ...
• Breaking a bitmask down in SQL

I have an old database design I'm working with that uses bitmasks. I have table that houses email addresses and a bitmask based on another table, and have been tasked with writing a SQL query which "...
• Statistical probability of N contiguous true-bits in a sequence of bits?

Let's assume I have an N-bit stream of generated bits. (In my case 64kilobits.) Whats the probability of finding a sequence of X "all true" bits, contained within a stream of N bits. Where X = (2 to ...
• How to represent a 5 digit decimal value as a 24 bit value?

I'm trying to convert a 5 digit decimal value (ranging from 00001 to 99999) and somehow represent it as a 24-bit value split into 3 bytes but have tried every conversion and bitshift tactic I know, ...
• Is there a method to covert an array of 1's and 0's to an array of bytes?

I have a 96-element array of 1's and 0's (I can also use booleans) that I am using to store achievements in a game (0 if not unlocked, 1 if unlocked) that I want to encode as Base64 (to "save" the ...