【问题标题】:How to print roman numerals greater than 3,999?如何打印大于 3,999 的罗马数字?
【发布时间】:2017-08-23 16:03:22
【问题描述】:

我想将几个数字打印为罗马数字,但是

(format t "~@R~%" 4000)

在 SBCL 1.3.20 和使用 ccl 的类似错误中导致以下错误:

Number too large to print in Roman numerals: 4,000
   [Condition of type SIMPLE-ERROR]

Restarts:
 0: [RETRY] Retry SLIME REPL evaluation request.
 1: [*ABORT] Return to SLIME's top level.
 2: [ABORT] abort thread (#<THREAD "new-repl-thread" RUNNING {100503D2B3}>)

我在Hyperspec 中没有找到有关此限制的任何信息,也不知道罗马人的数字只有 3,999。

是否有现成的解决方案可以将大于 3,999 的数字打印为罗马数字?

【问题讨论】:

  • 其实这不是 Common Lisp 的限制,而是罗马数字固有的东西。对于超过 3999 的数字,罗马人在一个数字上添加一条线以将其乘以 1000。

标签: format common-lisp roman-numerals


【解决方案1】:

罗马人对large number representation 没有达成共识。 CL 实现者反对解决争议,特别是因为罗马人使用的两种方法(“撇号”和“vinculum”)都不适合在 TTY 上用 ASCII 表示。

PS。 3.999 可以近似为 IV ;-)

【讨论】:

  • 我将数字格式编辑为英文标准 ;-)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-01-17
  • 1970-01-01
  • 2015-05-16
  • 1970-01-01
相关资源
最近更新 更多