binary

UTF-16 representation of arbitrarily long binary string

UTF-16 representation of arbitrarily long binary string Question: I have binary strings and want to store them as compactly (in terms of disk space) as possible. They can be between 1 and ~1000 bits of the form ‘011010010110100110010101’. Storing these as "TEXT" is wasteful. I’d like to retrieve and convert them back to the original …

Total answers: 1

how to make binary to bit 8 in python

how to make binary to bit 8 in python Question: i have variable contains with binary with type int ([101, 1101, 11001]) but i want to xor it with another variable, so i must change to string and add "0" so it has 8 number example 101 it’ll become 00000101 i was trying change int …

Total answers: 2

change a numeric column to binary?

change a numeric column to binary? Question: My problem is the following: Create a binary variable in which: =1 indicates that the house was sold for over $200,000 =0 indicates that the house was sold for less than or equal to $200,000 sac.loc[sac["price"]> 200000]= 1 sac.loc[sac["price"]<= 200000]= 0 It changes all the values ​​to 0 …

Total answers: 1

Integer equivalence of binary number that is represented as an integer in Python

Integer equivalence of binary number that is represented as an integer in Python Question: I have an input a=int(1010). I want to find integer equivalence of binary 1010. If I use bin(a) then output will be 1111110010, but I want to get 10. Asked By: Lee || Source Answers: You need to tell python, that …

Total answers: 1

Get all combinations of a binary string with bit flips at specific indices (Python)

Get all combinations of a binary string with bit flips at specific indices (Python) Question: I have a binary string. I have a list of bit indices to flip. How can I generate all possible combinations of binary strings with flips at those specific indices? The output list should contain 2^n unique elements where n …

Total answers: 3

Python itertools.groupby gives unexpected results when sorting by binary representation

Python itertools.groupby gives unexpected results when sorting by binary representation Question: I am trying to solve a simple problem using itertools.groupby: group the numbers from 0 to 7 according to the number of 1‘s in their binary representation. So I want to produce the mapping {0: [0], 1: [1, 2, 4], 2: [3, 5, 6], …

Total answers: 1

How to count int input using python

How to count int input using python Question: so i have func that convert bytes to binary and i want to count how many amount binary. example b’xd8xe9xbdR’ binary is 11011000 11101001 10111101 01010010 if it is count how many amount, it will be count 4. i already tried using split, but it says only …

Total answers: 1

how to use bitwise operators with binary strings in python

how to use bitwise operators with binary strings in python Question: so i have binary and i want to XOR every letters, like the example binary from word "maru" : m = 1101101 a = 1100001 XOR = result1 -> get result 1 r = 1110010 XOR = result2 -> result1 will be XOR with …

Total answers: 2