I’m ‘hacking’ my router, and I need to rewrite one JS function that takes date in hexdec format and convert it into Y m d
JS code looks like:
return [(((n >> 16) & 0xFF) + 1900), ((n >>> 8) & 0xFF), (n & 0xFF)];
where n is variable in format 0x123456 (e.g. 6 hexdec digits after 0x sign)
found that python has operators like >> but does’t have >>> operator.
Any idea how to do that ?
thanks
First thing you should know is that the bitwise operator for JS is operating on 32bit data. While for python, it’s assuming the data could have infinite number of bits.
So ‘>>’ in JS which is called signed-propagating right shift, should equal to
‘>>>’ in JS is called zero-fill right shift, in python since it always fill with zero, so you could just use ‘>>’. A more robust way to make sure it has same result with js