Bitwise operation alternative in Neo4j cypher query -


i need bitwise "and" in cypher query. seems cypher not support bitwise operations. suggestions alternatives? want detect ... example 268 (2^8 + 2^3 + 2^2) , can see 2^3 = 8 part of original number. if use bitwise , (100001100) & (1000) = 1000 way can detect if 8 part of 268 or not. how can without bitwise support? suggestions? need in cypher.

another way perform type of test using cypher convert decimal values collections of decimals represent bits set.

// convert binary number collection of decimal parts // create index size of number convert // create collection of decimals correspond bit locations '100001100' number , [1,2,4,8,16,32,64,128,256,512,1024,2048,4096] decimals number , range(length(number)-1,0,-1) index , decimals[0..length(number)] decimals  // map bits decimal equivalents unwind index number, i, (split(number,''))[i] binary_placeholder, decimals[-i-1] decimal_placeholder  // multiply decimal value bits set collect(decimal_placeholder * toint(binary_placeholder)) decimal_placeholders  // filter out 0 values collection filter(d in decimal_placeholders d > 0) decimal_placeholders return decimal_placeholders 

here sample of returns.

enter image description here

then when want test whether number in decimal, can test actual decimal presence in collection.

with [4, 8, 256] decimal_placeholders , 8 decimal_to_test return    case      when decimal_to_test in decimal_placeholders       tostring(decimal_to_test) + ' value bit set'     else       tostring(decimal_to_test) + ' value bit not set'     end bit_set_test 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -