-
-
Save ryanguill/3129961 to your computer and use it in GitHub Desktop.
BitAnd exercise
This file contains hidden or 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
<cffunction name="valueSearch2" returntype="string" access="remote"> | |
<cfargument name="input" type="numeric" required="true"/> | |
<cfset var local.msg = ''> | |
<cfset local.bitAR = arrayNew(1) /> | |
<cfset local.bitAR[1] = { bit = 256, name = 'Authority' } /> | |
<cfset local.bitAR[2] = { bit = 128, name = 'Claims' } /> | |
<cfset local.bitAR[3] = { bit = 64, name = 'Service Failure' } /> | |
<cfset local.bitAR[4] = { bit = 32, name = 'Safety Rating' } /> | |
<cfset local.bitAR[5] = { bit = 16, name = 'Pending Authority' } /> | |
<cfset local.bitAR[6] = { bit = 8, name = 'Profile' } /> | |
<cfset local.bitAR[7] = { bit = 4, name = 'Agreement' } /> | |
<cfset local.bitAR[8] = { bit = 2, name = 'W9' } /> | |
<cfset local.bitAR[9] = { bit = 1, name = 'Insurance' } /> | |
<cfset local.bitAR[10] = { bit = 512, name = 'Other' } /> | |
<cfloop from="1" to="#arrayLen(local.bitAR)#" index="local.i"> | |
<cfif bitAnd(arguments.input,local.bitAR[local.i]["bit"])> | |
<cfset local.msg = listAppend(local.msg,bitAR[local.i]["name"]) /> | |
</cfif> | |
</cfloop> | |
<cfreturn local.msg> | |
</cffunction> |
This file contains hidden or 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
<cfinvoke component="bitSearch" method="valueSearch2" returnvariable="result"> | |
<cfinvokeargument name="input" value="10"> | |
</cfinvoke> | |
<cfdump var="#result#"/> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment