Re: isValid - numeric vs. float
Agreed. I would recommend stripping the commas out before you validate the number. They do strange things with calculations. For instance, numberFormat() converts 1,000 to 41274, as does JavaCast(int,1,000) or JavaCast(float,1,000). I actually think its kind of incorrect that the default behavior for numberFormat(1000) returns 1,000 as it can mess up your calculations, but its been the default for so long, it would probably break backward compatibility for a bunch of apps. On Dec 3, 2013, at 7:35 PM, Adam Cameron dacc...@gmail.com wrote: It's a bug. There's no reason 1,000.00 should validate as a numeric value of any kind; and float is a subset of numeric. Railo returns false for both. As does OpenBD. -- Adam On 3 December 2013 22:05, Scott Brady dsbr...@gmail.com wrote: The docs for isValid() imply that the type numeric and float are equivalent, in that they're listed together. However, they can yield different results: isValid(numeric,1,000.00) returns false isValid(float,1,000.00) returns true This came up as we're dealing with an issue of users entering 1,000.00 [or something similar] into a field, which can cause problems in one area of code where we need that value to be a valid number (i.e., we want to use it in a calculation, which results in an error). We can use lsParseNumber(0 around the value, but first we need to make sure it's a valid number anyway. So, we're somewhat forced into using isValid(float,) which is fine. But, is this a bug with the actual isValid() function or is it more of a documentation error (i.e., behind the scenes, float and numeric are different and 1,000.00 is not a valid numeric but is a valid float)? Scott -- - Scott Brady http://www.scottbrady.net/ ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:357270 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: isValid - numeric vs. float
That's what we thought. I've submitted a bug report. Thanks! Scott On Tue, Dec 3, 2013 at 6:35 PM, Adam Cameron dacc...@gmail.com wrote: It's a bug. There's no reason 1,000.00 should validate as a numeric value of any kind; and float is a subset of numeric. Railo returns false for both. As does OpenBD. -- Adam On 3 December 2013 22:05, Scott Brady dsbr...@gmail.com wrote: The docs for isValid() imply that the type numeric and float are equivalent, in that they're listed together. However, they can yield different results: isValid(numeric,1,000.00) returns false isValid(float,1,000.00) returns true This came up as we're dealing with an issue of users entering 1,000.00 [or something similar] into a field, which can cause problems in one area of code where we need that value to be a valid number (i.e., we want to use it in a calculation, which results in an error). We can use lsParseNumber(0 around the value, but first we need to make sure it's a valid number anyway. So, we're somewhat forced into using isValid(float,) which is fine. But, is this a bug with the actual isValid() function or is it more of a documentation error (i.e., behind the scenes, float and numeric are different and 1,000.00 is not a valid numeric but is a valid float)? Scott -- - Scott Brady http://www.scottbrady.net/ ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:357269 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: isValid - numeric vs. float
Well, in our case, this started out as a way for us to determine if the variable we're dealing with is a number that we'd need to strip the commas from. Due to the nature of our code, we only want to strip out the commas if it's a number. For us, the bug actually works in our favor, because that's really the only way to determine if it was a number. (Our other alternative was to do an lsPareNumber() inside a try/catch block, which may be the way we have to go if Adobe fixes the bug. Scott On Wed, Dec 4, 2013 at 8:27 AM, Jon Clausen jon_clau...@silowebworks.comwrote: Agreed. I would recommend stripping the commas out before you validate the number. They do strange things with calculations. For instance, numberFormat() converts 1,000 to 41274, as does JavaCast(int,1,000) or JavaCast(float,1,000). I actually think its kind of incorrect that the default behavior for numberFormat(1000) returns 1,000 as it can mess up your calculations, but its been the default for so long, it would probably break backward compatibility for a bunch of apps. On Dec 3, 2013, at 7:35 PM, Adam Cameron dacc...@gmail.com wrote: It's a bug. There's no reason 1,000.00 should validate as a numeric value of any kind; and float is a subset of numeric. Railo returns false for both. As does OpenBD. -- Adam On 3 December 2013 22:05, Scott Brady dsbr...@gmail.com wrote: The docs for isValid() imply that the type numeric and float are equivalent, in that they're listed together. However, they can yield different results: isValid(numeric,1,000.00) returns false isValid(float,1,000.00) returns true This came up as we're dealing with an issue of users entering 1,000.00 [or something similar] into a field, which can cause problems in one area of code where we need that value to be a valid number (i.e., we want to use it in a calculation, which results in an error). We can use lsParseNumber(0 around the value, but first we need to make sure it's a valid number anyway. So, we're somewhat forced into using isValid(float,) which is fine. But, is this a bug with the actual isValid() function or is it more of a documentation error (i.e., behind the scenes, float and numeric are different and 1,000.00 is not a valid numeric but is a valid float)? Scott -- - Scott Brady http://www.scottbrady.net/ ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:357271 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: isValid - numeric vs. float
Scott, Ok.. this is simple but remember that val( ) actually returns a number if the first part of the string IS a number, and a zero if it is not: Val(343,200) returns 343 Val(ABC123) returns 0.00 So if you know you are dealing numbers above zero you can use this as a quick and easy Boolean function. As in If(val(23,320,2300.00)) { ..then whatever code you need to strip commas and further manage the variable. ) Just a thought :) Mark Kruger - CFG CF Webtools www.cfwebtools.com www.coldfusionmuse.com O: 402.932.3318 E: mkru...@cfwebtools.com Skype: markakruger -Original Message- From: Scott Brady [mailto:dsbr...@gmail.com] Sent: Wednesday, December 04, 2013 8:34 AM To: cf-talk Subject: Re: isValid - numeric vs. float Well, in our case, this started out as a way for us to determine if the variable we're dealing with is a number that we'd need to strip the commas from. Due to the nature of our code, we only want to strip out the commas if it's a number. For us, the bug actually works in our favor, because that's really the only way to determine if it was a number. (Our other alternative was to do an lsPareNumber() inside a try/catch block, which may be the way we have to go if Adobe fixes the bug. Scott On Wed, Dec 4, 2013 at 8:27 AM, Jon Clausen jon_clau...@silowebworks.comwrote: Agreed. I would recommend stripping the commas out before you validate the number. They do strange things with calculations. For instance, numberFormat() converts 1,000 to 41274, as does JavaCast(int,1,000) or JavaCast(float,1,000). I actually think its kind of incorrect that the default behavior for numberFormat(1000) returns 1,000 as it can mess up your calculations, but its been the default for so long, it would probably break backward compatibility for a bunch of apps. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:357272 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: isValid - numeric vs. float
But if the variable contains a street address like 1313 Mockingbird Lane then val() would make us think it's numeric data. In this case, this could be data that is supposed to be numeric but may not be . Kind of a silly example. I guess if lsParaeNumber() returned something like NAN for non-numeric arguments it would be simpler. On Dec 4, 2013, at 8:53 AM, Mark A Kruger mkru...@cfwebtools.com wrote: Scott, Ok.. this is simple but remember that val( ) actually returns a number if the first part of the string IS a number, and a zero if it is not: Val(343,200) returns 343 Val(ABC123) returns 0.00 So if you know you are dealing numbers above zero you can use this as a quick and easy Boolean function. As in If(val(23,320,2300.00)) { ..then whatever code you need to strip commas and further manage the variable. ) Just a thought :) Mark Kruger - CFG CF Webtools www.cfwebtools.com www.coldfusionmuse.com O: 402.932.3318 E: mkru...@cfwebtools.com Skype: markakruger -Original Message- From: Scott Brady [mailto:dsbr...@gmail.com] Sent: Wednesday, December 04, 2013 8:34 AM To: cf-talk Subject: Re: isValid - numeric vs. float Well, in our case, this started out as a way for us to determine if the variable we're dealing with is a number that we'd need to strip the commas from. Due to the nature of our code, we only want to strip out the commas if it's a number. For us, the bug actually works in our favor, because that's really the only way to determine if it was a number. (Our other alternative was to do an lsPareNumber() inside a try/catch block, which may be the way we have to go if Adobe fixes the bug. Scott On Wed, Dec 4, 2013 at 8:27 AM, Jon Clausen jon_clau...@silowebworks.comwrote: Agreed. I would recommend stripping the commas out before you validate the number. They do strange things with calculations. For instance, numberFormat() converts â1,000â to 41274, as does JavaCast(âintâ,â1,000) or JavaCast(âfloatâ,â1,000). I actually think itâs kind of incorrect that the default behavior for numberFormat(1000) returns 1,000 as it can mess up your calculations, but itâs been the default for so long, it would probably break backward compatibility for a bunch of apps. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:357280 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: isValid - numeric vs. float
that's true :) it all depends on where your variable is coming from and how predictable it is. Sent from my iPhone On Dec 4, 2013, at 12:40 PM, Scott Brady dsbr...@gmail.com wrote: But if the variable contains a street address like 1313 Mockingbird Lane then val() would make us think it's numeric data. In this case, this could be data that is supposed to be numeric but may not be . Kind of a silly example. I guess if lsParaeNumber() returned something like NAN for non-numeric arguments it would be simpler. On Dec 4, 2013, at 8:53 AM, Mark A Kruger mkru...@cfwebtools.com wrote: Scott, Ok.. this is simple but remember that val( ) actually returns a number if the first part of the string IS a number, and a zero if it is not: Val(343,200) returns 343 Val(ABC123) returns 0.00 So if you know you are dealing numbers above zero you can use this as a quick and easy Boolean function. As in If(val(23,320,2300.00)) { ..then whatever code you need to strip commas and further manage the variable. ) Just a thought :) Mark Kruger - CFG CF Webtools www.cfwebtools.com www.coldfusionmuse.com O: 402.932.3318 E: mkru...@cfwebtools.com Skype: markakruger -Original Message- From: Scott Brady [mailto:dsbr...@gmail.com] Sent: Wednesday, December 04, 2013 8:34 AM To: cf-talk Subject: Re: isValid - numeric vs. float Well, in our case, this started out as a way for us to determine if the variable we're dealing with is a number that we'd need to strip the commas from. Due to the nature of our code, we only want to strip out the commas if it's a number. For us, the bug actually works in our favor, because that's really the only way to determine if it was a number. (Our other alternative was to do an lsPareNumber() inside a try/catch block, which may be the way we have to go if Adobe fixes the bug. Scott On Wed, Dec 4, 2013 at 8:27 AM, Jon Clausen jon_clau...@silowebworks.comwrote: Agreed. I would recommend stripping the commas out before you validate the number. They do strange things with calculations. For instance, numberFormat() converts â1,000â to 41274, as does JavaCast(âintâ,â1,000) or JavaCast(âfloatâ,â1,000). I actually think itâs kind of incorrect that the default behavior for numberFormat(1000) returns 1,000 as it can mess up your calculations, but itâs been the default for so long, it would probably break backward compatibility for a bunch of apps. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:357281 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
isValid - numeric vs. float
The docs for isValid() imply that the type numeric and float are equivalent, in that they're listed together. However, they can yield different results: isValid(numeric,1,000.00) returns false isValid(float,1,000.00) returns true This came up as we're dealing with an issue of users entering 1,000.00 [or something similar] into a field, which can cause problems in one area of code where we need that value to be a valid number (i.e., we want to use it in a calculation, which results in an error). We can use lsParseNumber(0 around the value, but first we need to make sure it's a valid number anyway. So, we're somewhat forced into using isValid(float,) which is fine. But, is this a bug with the actual isValid() function or is it more of a documentation error (i.e., behind the scenes, float and numeric are different and 1,000.00 is not a valid numeric but is a valid float)? Scott -- - Scott Brady http://www.scottbrady.net/ ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:357249 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: isValid - numeric vs. float
It's a bug. There's no reason 1,000.00 should validate as a numeric value of any kind; and float is a subset of numeric. Railo returns false for both. As does OpenBD. -- Adam On 3 December 2013 22:05, Scott Brady dsbr...@gmail.com wrote: The docs for isValid() imply that the type numeric and float are equivalent, in that they're listed together. However, they can yield different results: isValid(numeric,1,000.00) returns false isValid(float,1,000.00) returns true This came up as we're dealing with an issue of users entering 1,000.00 [or something similar] into a field, which can cause problems in one area of code where we need that value to be a valid number (i.e., we want to use it in a calculation, which results in an error). We can use lsParseNumber(0 around the value, but first we need to make sure it's a valid number anyway. So, we're somewhat forced into using isValid(float,) which is fine. But, is this a bug with the actual isValid() function or is it more of a documentation error (i.e., behind the scenes, float and numeric are different and 1,000.00 is not a valid numeric but is a valid float)? Scott -- - Scott Brady http://www.scottbrady.net/ ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:357257 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm