Example of #to_s "eating" leading zeros:

rb(main):001:0> require 'digest/sha2'
=> true
irb(main):002:0> d = Digest::SHA256.hexdigest(3.chr+229.chr+245.chr)
=> "00000e302c2fd880c1615ce3104289c8fc142b30e10963d4a32fe7371e0f36b7"
irb(main):003:0> i = d.to_i(16)
=> 97923179718509917028425247791037714012132138545410096732043674779596471
irb(main):004:0> b = i.to_s(2)
=> "11100011000000101100001011111101100010000000110000010110000101011100111000110001000001000010100010011100100011111100000101000010101100110000111000010000100101100011110101001010001100101111111001110011011100011110000011110011011010110111"
irb(main):005:0> b.length
=> 236

Note also:

irb(main):006:0> i.to_s.length
=> 71

...That #to_s does not include the leading zeros we expect because we
know that we started with a 256-bit hash.

Aaron out.