S
sqlvs
Good citizens of Gotham,
I'm encountering an odd problem when comparing two values converted to
type double, as follows (please pardon the per-line script blocks):
<%="|" & CDbl(rsBatch("BatchTotal")) & "|" %><br>
<%="|" & CDbl(rsBatch("BatchPayments")) & "|" %><br>
<%= CDbl(rsBatch("BatchTotal")) = CDbl(rsBatch("BatchPayments"))
%><br>
<%= CDbl(rsBatch("BatchTotal")) - CDbl(rsBatch("BatchPayments"))
%><br>
<%= CDbl(rsBatch("BatchTotal")) - CDbl(rsBatch("BatchPayments")) = 0
%><br>
First two values (piping chars to ensure that unseen leading or
trailing spaces aren't present):
|126266.26|
|126266.26|
False
-1.45519152283669E-11
False
Second two values:
|43|
|80|
False
-37
False
For the second pair, "-37" is the difference between the two values
which, of course, are not equal. But why aren't the values in the
first pair equal? I have a feeling the clue is in the result
"-1.45519152283669E-11," and that I'm missing some fundamental piece
of obscurata here.
I ended up just using a string comparison (if CStr([rsvalue]) =
CStr([rsvalue])), but it seems like a comparison of the type
appropriate for dollar amounts (double) is the "right" way to do it.
Any ideas?
I'm encountering an odd problem when comparing two values converted to
type double, as follows (please pardon the per-line script blocks):
<%="|" & CDbl(rsBatch("BatchTotal")) & "|" %><br>
<%="|" & CDbl(rsBatch("BatchPayments")) & "|" %><br>
<%= CDbl(rsBatch("BatchTotal")) = CDbl(rsBatch("BatchPayments"))
%><br>
<%= CDbl(rsBatch("BatchTotal")) - CDbl(rsBatch("BatchPayments"))
%><br>
<%= CDbl(rsBatch("BatchTotal")) - CDbl(rsBatch("BatchPayments")) = 0
%><br>
First two values (piping chars to ensure that unseen leading or
trailing spaces aren't present):
|126266.26|
|126266.26|
False
-1.45519152283669E-11
False
Second two values:
|43|
|80|
False
-37
False
For the second pair, "-37" is the difference between the two values
which, of course, are not equal. But why aren't the values in the
first pair equal? I have a feeling the clue is in the result
"-1.45519152283669E-11," and that I'm missing some fundamental piece
of obscurata here.
I ended up just using a string comparison (if CStr([rsvalue]) =
CStr([rsvalue])), but it seems like a comparison of the type
appropriate for dollar amounts (double) is the "right" way to do it.
Any ideas?