logical "or" over number

The built-in bitwise XOR:
https://wiki.mikrotik.com/wiki/Manual:Scripting#Bitwise_Operators
should work also for IPv6 and num data types:

Bitwise Operators

Bitwise operators are working on number, IP and IPv6 address data types.

So, using your code but with IPv6 (and : instead of . as separator) you should be able to get at 8 digits.

Otherwise you would probably need to convert the binary to num, and then the result back to binary, rextended has posted:
http://forum.mikrotik.com/t/rextended-fragments-of-snippets/151033/18
http://forum.mikrotik.com/t/rextended-fragments-of-snippets/151033/18