Sorry, we might need to re-open this.

To mirror CF, the valid range of integers is -(2^31) to (2^31)-1.

However - as this code demonstrates - you're accepting out-of-bounds
values:

<cfset lTests = "#(-(2^31))-1#,#-
(2^31)#,-1,0,1,#(2^31)+1#,#((2^31)+1)+1#">

<cfsavecontent variable="lTests">
        <cfoutput>
        #(-(2^31))-1#,  <!--- too low: fail --->
        #-(2^31)#,              <!--- minimum valid --->
        -1,                             <!--- control --->
        0,                              <!--- control --->
        1,                              <!--- control --->
        #(2^31)-1#,             <!--- maximum value --->
        #((2^31)-1)+1#  <!--- too high: fail --->
        </cfoutput>
</cfsavecontent>
<cfloop index="nTest" list="#lTests#">
        <cfset nTest = trim(nTest)>
        <cfoutput>isValid("integer", #nTest#): #isValid("integer",
nTest)#<br /></cfoutput>
</cfloop>


isValid("integer", -2147483649): YES
isValid("integer", -2147483648): YES
isValid("integer", -1): YES
isValid("integer", 0): YES
isValid("integer", 1): YES
isValid("integer", 2147483647): YES
isValid("integer", 2147483648): YES

(CF fails the first and last).

This could be for two reasons I can think of:
1) OBD uses a different integer range than CF does.  This would be
fair enough.  If so, what's the range?  IE: what's OBD's equivalent
construct to java.lang.Integer's MAX_VALUE / MIN_VALUE figures.
2) your isValid("integer") test does something like just checking it
it's numeric and has no decimal part.  This would be fair enough in
the "real world", but I think in the computer world, a number is only
an integer it fits into an integer data type.

Can you pls clarify?

Cheers.

--
Adam




On Jul 9, 7:38 am, Adam Cameron <[email protected]> wrote:
> Cool: that worked Alan, cheers.
>
> --
> Adam
>
> On Jul 9, 6:42 am, "Alan Williamson (aw2.0 ltd)" <[email protected]>
> wrote:
>
>
>
>
>
>
>
> > Thanks Adam for spotting this and reporting it.
>
> > I have committed a fix for this and you can download it from the nightly
> > build from the main site.
>
> > All is well again.
>
> > <cfloop>
> > isValid("integer", 1): YES
> > isValid("integer", 2): YES
> > isValid("integer", 3): YES
> > isValid("integer", 4): YES
> > isValid("integer", 5): YES
> > isValid("integer", 6): YES
> > isValid("integer", 7): YES
> > isValid("integer", 8): YES
> > isValid("integer", 9): YES
> > isValid("integer", 10): YES
>
> > for ()
> > isValid("integer", 2): YES
> > isValid("integer", 3): YES
> > isValid("integer", 4): YES
> > isValid("integer", 5): YES
> > isValid("integer", 6): YES
> > isValid("integer", 7): YES
> > isValid("integer", 8): YES
> > isValid("integer", 9): YES
> > isValid("integer", 10): YES

-- 
Open BlueDragon Public Mailing List
 http://www.openbluedragon.org/   http://twitter.com/OpenBlueDragon
 online manual: http://www.openbluedragon.org/manual/

 mailing list - http://groups.google.com/group/openbd?hl=en

Reply via email to