簡體   English   中英

vbscript數學表達式不起作用

[英]vbscript mathematical expression not working

在我的ASP代碼中,我有4個具有不同值的變量。

chAmount = 19.99
totalRefundAmount =0
voidQueueRefundAmount =15.99
amount=4

當我執行以下語句

if (CDbl(chAmount) + CDbl(totalRefundAmount) - CDbl(voidQueueRefundAmount) - CDbl(amount) < 0.00) then
end if

if條件為true,但不應該是因為上述表達式的答案應該為0,並且不應進入if循環,而是進入循環內部。

我在Visual Studio調試器中得到表達式CDbl(chAmount) + CDbl(totalRefundAmount) - CDbl(voidQueueRefundAmount) - CDbl(amount) -1.77635683940025E-15

請參見以下Visual Studio調試器的屏幕截圖。 http://screencast.com/t/73PyutXB07R1

這是因為您要轉換為的Double是一個浮點數。

在處理貨幣時,為什么要轉換為Double 使用CCur()代替CDbl()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM