spec/int_spec.rb in bindata-1.4.5 vs spec/int_spec.rb in bindata-1.5.0
- old
+ new
@@ -127,10 +127,10 @@
# resulting int is guaranteed to be +ve for signed or unsigned integers
(0 ... @nbytes).inject(0) { |val, i| (val << 8) | ((val + 0x11) % 0x100) }
end
def int_to_binary_str(val)
- str = ""
+ str = binary("")
v = val & ((1 << (@nbytes * 8)) - 1)
@nbytes.times do
str.concat(v & 0xff)
v >>= 8
end