Created
September 10, 2020 13:49
-
-
Save trycf/14bea07bc4311e74b5c06cc93b1280ad to your computer and use it in GitHub Desktop.
TryCF Gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
function isPositive(required numeric input, boolean debug=false) output=true { | |
var absValue = abs(arguments.input); | |
if( arguments.debug ){ | |
writeDump({ | |
"input"=arguments.input | |
, "absValue"=absValue | |
, "result"=(absValue == arguments.input) | |
, "result_when_cast_to_double"=(absValue == javaCast("double", arguments.input)) | |
}); | |
} | |
return (absValue == arguments.input); | |
} | |
testValue = "0.08263888888888889"; | |
writeOutput("Should be true == #isPositive(testValue)#"); | |
isPositive(testValue, true); | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment