我正在尝试学习C并且遇到无法使用真正的大数字(即100位,1000位等).我知道存在这样做的库,但我想尝试自己实现它.
我只是想知道是否有人或者可以提供任意精度算术的非常详细,愚蠢的解释.
我目前正在教自己Ada,虽然我可以从解决一些更传统的问题开始.
更具体地说,我尝试计算阶乘n !,而n> 100.到目前为止,我的实施是:
with Ada.Text_IO;
with Ada.Integer_Text_IO;
use Ada.Text_IO;
procedure Factorial is
-- define a type covering the range beginning at 1 up to which faculty is to
-- be computed.
subtype Argument is Long_Long_Integer range 1..100;
-- define a type that is large enough to hold the result
subtype Result is Long_Long_Integer range 1..Long_Long_Integer'Last;
package Result_IO is new Ada.Text_IO.Integer_IO(Result); use Result_IO;
-- variable holding the faculty calculated.
fac : Result := 1;
begin
-- loop over whole range …Run Code Online (Sandbox Code Playgroud) 我一直在阅读一篇关于密码学的文章,我自己也想到"32位计算机如何实现512位值,甚至64位值的操作?"
有人能指出我正确的方向吗?也许我不知道如何恰当地表达我想知道的内容,但谷歌搜索对于解决这个问题并不是很有帮助.
谢谢!