thats excellent rex thanks very much for your help :)
richard
>All numeric data types in CF are typed as Java Strings. You must do a
>JavaCast() to type BigDecimal and do comparisons on that. Here is your
>modified code:
>
><cffunction name="isValidFloatRange" hint="is passed a value, a min
>range, and a max range and checks to ensure the value is in between the
>2 ranges">
> <cfargument name="value" type="numeric" required="true">
> <cfargument name="minRange" type="numeric" required="true">
> <cfargument name="maxRange" type="numeric" required="true">
>
> <cfset var xvalue = javacast("bigdecimal", ARGUMENTS.value) />
> <cfset var xminRange = javacast("bigdecimal", ARGUMENTS.minRange) />
> <cfset var xmaxRange = javacast("bigdecimal", ARGUMENTS.maxRange) />
>
> <cfif xminRange.compareTo(xmaxRange) GTE 0>
> <cfreturn "Error in Range: #maxRange# must be larger than
> #minRange#)" />
> </cfif>
>
> <cfif (xvalue.compareTo(xminRange) EQ -1) or
>(xvalue.compareTo(xmaxRange) EQ 1)>
> <cfreturn "Float out of range: #value# (Valid Float Range:
> #minRange#
>to #maxRange#)" />
> <cfelse>
> <cfreturn true>
> </cfif>
></cffunction>
>
><cfoutput>
> #isValidFloatRange(1.9999999999999999999999999999999,1,3)#<br />
> #isValidFloatRange(1,1,3)#<br />
> #isValidFloatRange(2,1,3)#<br />
> #isValidFloatRange(2.99999999999999999999999999999999999,1,3)#<br />
> #isValidFloatRange(3.00000000000000000000000000001,1,3)#<br />
>
> #isValidFloatRange(0.9999999999999999999999999999999999999999999,1,3)#<br
>/>
>
> #isValidFloatRange(1.000000000111111111111111111111111111111111111,1,3)#<br
>/>
></cfoutput>
>
>Make sure to VAR your functions, and I've set a validation against
>switched max/min Ranges (or you can just switch them)
>
>Richard White wrote:
>>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:313643
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4