Re: ('1,1') * 1 = 39448

2008-07-22 Thread Bert Dawson
I should have spotted that: i noticed that the difference between 0,1 and
0,2 and 0,3 were 31, 29 and 31, etc. And also that the sequences jumped when
the numbers went from 12 to 13, and likewise around 30. And also leaps of
365 and 366 between 1,32 and 1,33 and 1,34 etc.

So CF is saying, well, 1,1 isn't a number, but might be a date, then getting
the number of days from 1 jan 1900 (or 30 dec 1988) to 1st Jan 2008 and use
that in the calculation.

Well, at least there is an explanation, but personally i can't see the point
in a feature which interprets 1,1 and 12,13 and 13,12 and 12,53 etc as
dates, and that any code which actively relied on such an abomination (as
oposed to falling victim to this feature) should be taken out and shot.

But looking on the bright side, we shouldn't have anymore customers getting
charged $1,143,992 for something they were expecting to pay $29 for...

Cheers
Bert



On Tue, Jul 22, 2008 at 5:43 PM, Experienced CF Developer <
[EMAIL PROTECTED]> wrote:

> 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":
>
> 
> #dateFormat(nValue,"mm/dd/")#
>
> 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.
>'1,1' * 1 = #'1,1' * 1#
> 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
>#'5,23' * 1# = #'23,5' * 1# = 39591
>
> 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:
>
> 
> 
>
>
>#wtf(i,j)#
>
>
> 
> 
>
> 
> function wtf(a,b) {
>var x = '#a#,#b#';
>try {
>return '#x#*1 = ' & x*1;
>}
>catch(Any E) {
>return '#x#*1 pukes';
>}
> }
> 
>
>
>
>
> 

~|
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:309498
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


RE: ('1,1') * 1 = 39448

2008-07-22 Thread Experienced CF Developer
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":


#dateFormat(nValue,"mm/dd/")#

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.
'1,1' * 1 = #'1,1' * 1#
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
#'5,23' * 1# = #'23,5' * 1# = 39591

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:





#wtf(i,j)#






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





~|
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