光庆大数计算库 - 除法计算精度测试

光庆 8月前 666 v 1.2 2024-03-03

运行以下代码前,请将godking.bigNum库升级到不低于V1.2:

import console; 
import godking.bigNum
var b = godking.bigNum("0xFFFFFFFFFFFFFFFF")	//18446744073709551615
console.log("当前精度:",10)
console.log("计算结果:",b/999063388)
console.log("原始数值:","18446744073709551615")
console.log("计算还原:",b/999063388*999063388)
console.log('\n')

..godking.bigNum.divAccuracy=5;
console.log("当前精度:",..godking.bigNum.divAccuracy)
console.log("计算结果:",b/999063388)
console.log("原始数值:","18446744073709551615")
console.log("计算还原:",b/999063388*999063388)
console.log('\n')

..godking.bigNum.divAccuracy=6;
console.log("精度要求不高的情况下,进行合理化四舍五入处理,计算精度设为6,四舍五入到小数点后5位:")
console.log("当前精度:",..godking.bigNum.divAccuracy)
console.log("计算结果:",(b/999063388).round(5))
console.log("原始数值:","18446744073709551615")
console.log("计算还原:",(b/999063388).round(5)*999063388)
console.log('\n')

console.pause(true);

上传的附件:
最新回复 (2)
  • Viewer8122 8月前
    0 2
    谢谢分享。
  • kio 8月前
    0 3
    还是卢哥厉害
返回