From: "Ara.T.Howard" Date: 2004-02-19T02:04:53+09:00 Subject: Re: Ruby 1.8.1: Unexpected "pack" result On Wed, 18 Feb 2004, Ara.T.Howard wrote: this version is even more informative... ~ > cat int_max.rb require 'tmpdir' require 'ftools' c_prog = <<-code #include main(){int i = INT_MAX; write(1,&i,sizeof(int));} code tmp = Dir::tmpdir a_c = File.join tmp, 'a.c' a_out = File.join tmp, 'a.out' out = File.join tmp, 'out' open(a_c, 'w'){|f| f.write c_prog} system "cc #{ a_c } -o #{ a_out }" system "#{ a_out } > #{ out }" int_max = IO.read(out).unpack('i').first p(int_max) p((2 ** 31) - 1) p("%032.32b" % int_max) p(0xFFFFFFFF) p((2 ** 32) - 1) p("%032.32b" % 0xFFFFFFFF) File.rm_f a_c File.rm_f a_out File.rm_f out -a -- =============================================================================== | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328 | URL :: http://www.ngdc.noaa.gov/stp/ | TRY :: for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done ===============================================================================