From: "リックス" Date: 2006-05-20T05:43:41+09:00 Subject: [ruby-list:42229] Hasu 関数の表示の仕方について おはようございます りっくすです hash関数で表示のしかたがうまく行きません おちえをはいしゃくください #!/usr/bin/ruby code=Hash.new(0) code["OUT 13"]=10111101 code["OUT 14"]=10111110 code["OUT 15"]=10111111 code_buf="OUT 13" buf=code[code_buf] printf("%08b\n",buf) #(i) #EOF 個のソースで 2進数を8桁表示させたいのですが 桁数が多くなってしまいます 以下のように表示されます [hana@localhost TD4_20060520]$ ./test.rb 100110100100100001111101 [hana@localhost TD4_20060520]$ (i)のところをprintf("%08b\n",buf.to_i(2)) とすると [hana@localhost TD4_20060520]$ ./test.rb ./test.rb:8:in `to_i': wrong number of arguments(1 for 0) (ArgumentError) from ./test.rb:8 [hana@localhost TD4_20060520]$ と言う風なエラーになってしまいます どうかアドバイスください PS 参考文献 Rubyプログラミング基礎講座 技術評論社 広瀬雄二著 -------------------------------------- Yahoo! JAPAN 10th Anniversary Special Feature --- Enjoy Yahoo! Auction with Yahoo! Mail !! --- http://pr.mail.yahoo.co.jp/auction/