Answered
Problems adding and subtracting - End up w/ Exponential value
I have a problem with a script i'm writing... Basically when
I subtract one vale from another and the product should be zero, i
end up with a exponential value insted. What is really strange,
most of the time it does come out with a correct balance of zero?
Here is the script... the values are stores as nvarchar on the SQL server.
ANY HELP WOULD BE GREATLY APPRECIATED!!! I Have been trying to figure this out for a couple of weeks now.
<cfset DebitTotal = 0>
<cfset CreditTotal = 0>
<cfset CreditAdjust = 0>
<cfset DebitAdjust = 0>
<cfoutput query="GetEntries">
<tr>
<td>#EntryDate#</td>
<td>#EntryDescription#</td>
<td>#EntryType#</td>
<td><cfif #Debit# EQ 0>
<cfelseif EntryType EQ 'RMA'>
(#Debit#)
<cfset DebitAdjust = #DebitAdjust# + #Debit#>
<cfelse>
#Debit#
<cfset DebitTotal = #Debit# + #DebitTotal#>
</cfif></td>
<td><cfif #Credit# EQ 0>
<cfelseif EntryType EQ 'CAA'>
(#Credit#)
<cfset CreditAdjust = #CreditAdjust# + #Credit#>
<cfelse>
#Credit#
<cfset CreditTotal = #CreditTotal# + #Credit#>
</cfif>
</td>
</tr>
</cfoutput>
<cfset CreditTotalAdjusted = #CreditTotal# - #CreditAdjust#>
<cfset DebitTotalAdjuested = #DebitTotal# - #DebitAdjust#>
<cfset Balance = #DebitTotalAdjuested# - #CreditTotalAdjusted#>
Here is the script... the values are stores as nvarchar on the SQL server.
ANY HELP WOULD BE GREATLY APPRECIATED!!! I Have been trying to figure this out for a couple of weeks now.
<cfset DebitTotal = 0>
<cfset CreditTotal = 0>
<cfset CreditAdjust = 0>
<cfset DebitAdjust = 0>
<cfoutput query="GetEntries">
<tr>
<td>#EntryDate#</td>
<td>#EntryDescription#</td>
<td>#EntryType#</td>
<td><cfif #Debit# EQ 0>
<cfelseif EntryType EQ 'RMA'>
(#Debit#)
<cfset DebitAdjust = #DebitAdjust# + #Debit#>
<cfelse>
#Debit#
<cfset DebitTotal = #Debit# + #DebitTotal#>
</cfif></td>
<td><cfif #Credit# EQ 0>
<cfelseif EntryType EQ 'CAA'>
(#Credit#)
<cfset CreditAdjust = #CreditAdjust# + #Credit#>
<cfelse>
#Credit#
<cfset CreditTotal = #CreditTotal# + #Credit#>
</cfif>
</td>
</tr>
</cfoutput>
<cfset CreditTotalAdjusted = #CreditTotal# - #CreditAdjust#>
<cfset DebitTotalAdjuested = #DebitTotal# - #DebitAdjust#>
<cfset Balance = #DebitTotalAdjuested# - #CreditTotalAdjusted#>