Looked like it could be a ColdFusion date value to me.  So I did a
dateFormat() on that and came up with "01/01/2008":

<cfset nValue = "1,1" * 1>
<cfoutput>#dateFormat(nValue,"mm/dd/yyyy")#<br><br></cfoutput>

It's assuming "1,1" is the current month and year.  I did the same for
"5,23" * 1 and got 05/23/2008.

What's really fun is if you do "1,1" * 2......

Go ahead... see what you get.....  10/15/2116

Now go figure THAT one out!

Dave Phillips

-----Original Message-----
From: Bert Dawson [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 22, 2008 5:08 PM
To: CF-Talk
Subject: ('1,1') * 1 = 39448

I tracked down a defect to a piece of code which basically did the
following:

total = form.quantity * form.itemamount

In some cases, form.quantity is commong through as *1,1* which is presumably
due to an HTML issue with duplicate form fields with the same name.

But rather than getting a CF error cos 1,1 isn't a number, it evaluates to
39448!

i.e.
    <cfoutput>'1,1' * 1 = #'1,1' * 1#</cfoutput>
produces:
   '1,1' * 1 = 39448

I'm not worried about the original problem with the form.quantity coming
though as *1,1* rather than the expected *1* since I can fix that, but i'm
curious as to any reason for this odd result.

It looks like (x,y) * 1 is the same as (y,x) * 1
In other words
    <cfoutput>#'5,23' * 1# = #'23,5' * 1# = 39591</cfoutput>

As i say, i'm not worried about fixing the defect, but i'm just curious if
there is an underlying explanation for the apparently wierd behaviour. Or is
it just a bug in the way CF does the conversion?

Cheers
Bert

p.s. FWIW here's a snippet which will create a 101 square grid of all the
combinations:

<table border="1">
<cfloop from="0" to="100" index="i">
    <tr>
        <cfloop from="0" to="100" index="j">
            <td nowrap="true">#wtf(i,j)#</td>
        </cfloop>
    </tr>
</cfloop>
</table>

<cfscript>
function wtf(a,b) {
    var x = '#a#,#b#';
    try {
        return '#x#*1 = ' & x*1;
    }
    catch(Any E) {
        return '#x#*1 pukes';
    }
}
</cfscript>




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:309490
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to