为什么ASP会这样?!!!!!!!!!!!1
19.5-0.55=1.40000004768372
???????????????????//
推荐阅读
数据是不是从数据库中读出的,如果是这是一个常见问题
我一般自己编程保留小数
源代码给你 java版
tmp 为要处理的数字
length 为要保留的位数
返回值为 结果
public double parsedouble(double tmp,int length) //解析double值
{
try
{
string res=new string();
int index;
res=string.valueof(tmp);
index=res.indexof(.);
res=res.substring(0,index+length);
return double.valueof(res).doublevalue();
}
catch(exception e)
{
e.printstacktrace();
return -1;
}
}
在什么环境中出的问题?
round(expression[, numdecimalplaces])
arguments
expression
required. numeric expression being rounded.
numdecimalplaces
optional. number indicating how many places to the right of the decimal are included in the rounding. if omitted, integers are returned by the round function.
remarks
the following example uses the round function to round a number to two decimal places:
dim myvar, pi
pi = 3.14159
myvar = round(pi, 2) myvar contains 3.14.
可以用formatnumber格式化表达式,或者先把参加操作的数据显式转换成需要的类型。然后再进行运算。一般这样解决因该市没有问题了。
刚才说的是用vbscript时的解决办法。在javascript中可以这样用numobj.tofixed([fractiondigits]),不过返回的是字符串。如果需要,再转成数字。
.

讨论区