Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
COBOLをRubyプログラムに変換するという冒険を続けて、10進数をcomp-3/パック10進数形式に変換する必要があります。これを行う簡単なRubyスクリプトまたはgemを知っている人はいますか?ベルンズ
Rubyはニブルを詰める方法を知っているので、非常に簡単であることがわかります。
def pack_comp(n) s = n.abs.to_s + (n < 0 ? "d" : "c") s = "0" + s if s.size.odd? [s].pack("H*") end