Category : binary

Im trying to open list with values and their hexa data and convert each line to only binary value (with small mask). For example in my txt file I have: DATA0 = 0x413e960d DATA1 = 0x1c1c81c7 DATA2 = 0xa0000000 (32 Bits) I want the output to be: 000000000000000001000001001111101001011000001101 000000000000000000011100000111001000000111000111 000000000000000010100000000000000000000000000000 (48 Bits) I want to ..

Read more

To solve the problem stated in this[1] exercise, I have been helped to the following solution: cols=int(input()) data=bin(int(input))[2:] data = [data[-i-1::-cols] for i in range(cols)] heights = [col.index("0") for col in data] print(max([(i,a) for i, a,b,c in enumerate(zip(heights[:-2], heights[1:-1], heights[2:])) if a==b==c], key=lambda x: x[1])[0]) However, line 2 returns a TypeError as stated in the ..

Read more

I am trying to convert positive and negative fractions to binary, I found the following approach online (https://www.geeksforgeeks.org/convert-decimal-fraction-binary-number/) to convert positive fractions to binary and tried to extend it to support the negative fractions. I am trying to do the 2’s complement on the fractional part. Any help is much appreciated. # decimal to binary ..

Read more