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 程序的冒险,我必须将十进制数字转换为 comp-3/压缩十进制格式。任何人都知道这样做的简单 Ruby 脚本或 gem 吗?伯恩斯
Ruby 知道如何打包 nibbles,所以这很容易:
def pack_comp(n) s = n.abs.to_s + (n < 0 ? "d" : "c") s = "0" + s if s.size.odd? [s].pack("H*") end