On Mar 21, 2006, at 11:28 PM, Wes Gamble wrote:

> I want to do:
>
> File.open(path_to_file, "r") do |f|
>         magic_number = f.read(8)
>         $stderr.print "Magic number is: #{magic_number}\n"
>       end
>
> but I want to print the bytes as HEX values - how do I do that?
>
> Thanks,
> Wes

Use printf/sprintf/%

Ex:
puts "%#x" % 100 -> 0x64

-- Daniel