python - How to 'and' data without ignoring digits? -
say have number, 18573628, each digit represents kind of flag, , want check if value of fourth flag set 7 or not (which is).
i not want use indexing. want in way and flag mask, such this:
00070000
i use np.logical_and() or that, consider any positive value true. how can and while considering value of digit? example, preforming operation
flags = 18573628
and
mask = 00070000
would yield 00010000
though trying different mask, such
mask = 00040000
would yield 00000000
what can is
if (x // 10**n % 10) == y: ... to check if n-th digit of x (counting right) equal y
Comments
Post a Comment