Numbers starting with 0 are interpreted as octal, just like numbers starting with 0x are interpreted as hexadecimal. 83 is represented as 123 in octal.
irb(main):001:0> 0123
=> 83
irb(main):002:0> 1*8**2 + 2*8**1 + 3*8**0
=> 83
irb(main):003:0> "%05d" % 0x7b
=> "00123"