Forth 中的大整数?

Big integer in Forth?

我在 Forth (ANS-94) 中开发了一个 big-integer system(用于动态长度的数字),但它太慢了。有没有可用的快速系统?

此外,欢迎提供有关该主题的任何提示。

The Forth Scientific Library includes Arithmetic on big signed-magnitude numbers 模块。虽然,需要进行测试以查看哪种实现速度更快。要在 SP-Forth 中使用这个模块,应该包含一些库:

REQUIRE [IF]    lib/include/tools.f
REQUIRE M+      lib/include/double.f

S" big.fth" INCLUDED \ just for example

无论如何,如果Forth生成的代码性能不够(并且算法已经优化),可以使用动态库(DLL,SO)形式的任何其他实现。

关于性能,在 SP-Forth 4.21 中最好使用动态内存(而不是字典 space)作为缓冲区,因为 data-space 和 code-space 是没有分开。