News for hackers. Stuff that matters.
Re:Do binary files contain more 1s or 0s? by oconnor663 on Tuesday November 12, 2019 @03:33PM (#21517845)
The reason you're measuring more 1's than 0's is this line:

  binary = bin(decimal)[2:]
That's because while `bin(0xff)` is indeed "0b11111111", `bin(0x00)` is "0b0". Python omits your leading zeros.

A smaller nit, these lines:

  hexadecimal = binascii.hexlify(byte)
  decimal = int(hexadecimal, 16)
can be just

  decimal = byte[0]
Re:Do binary files contain more 1s or 0s? by edent on Tuesday November 12, 2019 @03:40PM (#21517929)
D'oh! I swear I had a `.zfill(8)` in there. Looks like the whole thing is wrong. Oh well!