注册 登录
编程论坛 VB6论坛

谁帮我验证一下,这个大数计算结果是否正确,谢谢!

yuma 发布于 2023-05-28 13:06, 968 次点击
MsgBox BigNumAdd("12345678901234567890", "98765432109876543210")  ' 加法,显示 111111111111111111100
MsgBox BigNumSub("98765432109876543210", "12345678901234567890")  ' 减法,显示 86419753208641975320
MsgBox BigNumMul("123456789012345678901234567890", "987654321098765432109876543210")  ' 乘法,显示11932631126021795225085032733611923332231163801111113526900
MsgBox BigNumDiv("12193263113702179556720073558516635681494230864252625391052410", "987654321098765432109876543210")  '除法,显示123456788101234567924651296698834
5 回复
#2
风吹过b2023-05-28 16:57
用 windows 的计算器验证过了,有问题,除法没验证。
下面一行是你的结果

12345678901234567890+98765432109876543210=111111111011111111100
                     111111111111111111100

98765432109876543210-12345678901234567890=86419753208641975320
                     86419753208641975320

123456789012345678901234567890*987654321098765432109876543210=1.2193263113702179522618503273362e+59
                                11932631126021795225085032733611923332231163801111113526900


只有本站会员才能查看附件,请 登录

只有本站会员才能查看附件,请 登录

只有本站会员才能查看附件,请 登录




[此贴子已经被作者于2023-5-28 17:14编辑过]

#3
yuma2023-05-28 19:30
感谢B哥。我这边两种代码验证,都是一致的。
#4
mrexcel2023-05-28 22:35
12193263113702179556720073558516635681494230864252625391052410/987654321098765432109876543210=12345678901234567924651296698834.390649879058393091920832319230325610567596706083...
#5
吹水佬2023-05-29 08:15
除法转乘法:b/a = b * 1/a,用牛顿迭代法求 a 的倒数。
迭代次数5次以上,小数位数60
BigNumDiv("12193263113702179556720073558516635681494230864252625391052410", "987654321098765432109876543210")
结果
第1次迭代:12343797224862214266873487394881.846538564100268358457178260419967233160553572966725260363900
第2次迭代:12345678614437381751280892115351.282460295172063868241617328477689495614720479132583385981243
第3次迭代:12345678901234561262188530982675.877830509035233917447990126775617661125101829186917439702213
第4次迭代:12345678901234567924651296698830.795188628230351311091135861646403434837478763595508472607633
第5次迭代:12345678901234567924651296698834.390649879058393091920832319229278495888069992280914886346969
第6次迭代:12345678901234567924651296698834.390649879058393091920832319230325610567596706083314103406283
第7次迭代:12345678901234567924651296698834.390649879058393091920832319230325610567596706083314103406283

#6
阳光上的桥2023-05-29 09:37
可以用PHP、PYTHON等现代语言验证,这些语言内置了对大数、复数的支持,而且速度很快,下面是PHP的执行情况:

echo bcmul("123456789012345678901234567890", "987654321098765432109876543210");
121932631137021795226185032733622923332237463801111263526900

echo bcdiv("12193263113702179556720073558516635681494230864252625391052410", "987654321098765432109876543210");
12345678901234567924651296698834
1