Hi there,
We have a requirement where we need to generate masked value, based on the selected checkbox,
For generating masked value, we will be required to perform bitwise or operation between the selected value of the checkbox.
let us say we have 4 checkbox
SUNDAY = 0
Monday = 1
Tuesday = 2
Thursday =3
now based on the user selection we need to perform the bitwise or operation between the selected value i.e
masked value |= (0,1,3)
is there any way to perform the bitwise or operation in Appian..?
Thanks in advance.
Discussion posts and replies are publicly visible
Can you tell us a bit more detail about what you're trying to do, and/or what you've already tried? Does the or() function not work for your purposes?
Hi Mike ,
Need to perform Bitwise OR operation between numbers.
So , In the above given example let us say user selected check box for sunday and monday and thrusday ,
in that case i need to generate masked value ,
masked Value formula will be
maskedValue = 0 | 1 | 3 i.e bitwise OR (0 ,1,3).
Looking forward for a way to perform bitwise or operation in appian.
No , or does not fit into our requirement.
Thank you for the inputs.
Hi Malay,
dec2bin would help you. With this function, you can transform a base-10 integer to a binary, represented as string. You can then iterate over the elements of the string and perform a bitwise operation of your choice. If you take an array containing n elements and iterate through it with the mid() function, you get a list of all relevant bit values, which you can then compare using or().
Kind of like the below sample, which I encourage you to use and test to see whether it fulfills for requirement. Let me know.
a!localVariables( local!places: len(dec2bin(max(ri!array))), local!binArray: dec2bin(ri!array,local!places), concat( a!forEach( items: enumerate(local!places)+1, expression: tointeger(or(mid(local!binArray,fv!item,1))) ) ) )
Hi Marcel,
"it worked like a silver bullet".
Thank you so much.