VBScript中的数学EX pression不工作 [英] vbscript mathematical expression not working
问题描述
在我的ASP code,我有4个变量的值不同。
In my asp code, I have 4 variables with different values.
chAmount = 19.99
totalRefundAmount =0
voidQueueRefundAmount =15.99
amount=4
当我执行以下语句
when I execute following statement
if (CDbl(chAmount) + CDbl(totalRefundAmount) - CDbl(voidQueueRefundAmount) - CDbl(amount) < 0.00) then
end if
。如果在它不应该是因为上述的前pression的答案应该是0,它不应该在循环若去,但它是在循环中去。条件是真
The if condition is true while it should not be because the answer of above expression should be 0 and it should not go in the if loop but it is going inside the loop .
我在Visual Studio调试器为前pression越来越-1.77635683940025E-15 CDbl(chAmount)+ CDbl(totalRefundAmount) - CDbl(voidQueueRefundAmount) - CDbl(量)
I am getting -1.77635683940025E-15 in the visual studio debugger for the expression CDbl(chAmount) + CDbl(totalRefundAmount) - CDbl(voidQueueRefundAmount) - CDbl(amount)
看到下面的Visual Studio调试器的屏幕截图。
http://screencast.com/t/73PyutXB07R1
see this following screenshot of visual studio debugger. http://screencast.com/t/73PyutXB07R1
推荐答案
这是因为双击
你转换为一个浮点。
That's because the Double
you're converting to is a floating point.
为什么转换为双击
当你正在处理的货币?使用 CCur函数()
而不是 CDbl()
。
Why convert to Double
when you are dealing with currencies? Use CCur()
instead of CDbl()
.
这篇关于VBScript中的数学EX pression不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!