栗子:add("2312421212512521111112421412412","123")
float型浮点数相加会出现问题,如0.1+0.3
不是在另外一个问题回答你了吗。。。需要用到大数运算类BigInt.js,看附件
<html><head>
<meta http-equiv="Content-Type" content="text/html charset=utf-8" />
<title>BigInt.html</title>
<script src="BigInt.js"></script>
<script>
// 大数运算
function bigCount(){
var a = new BigInt("100000000000000400")
var b = new BigInt("100000000000000300")
var c=bigint_plus(a,b)//大数加法
var d=bigint_minus(a,b)//大数减法
alert("和:"+c)
alert("差:"+d)
}
</script>
</head>
<body onload="bigCount()">
</body>
</html>