Attempting to convert a UID generator from Javascript to Ruby, I wanted to understand the following behavior.
this line of code
89190868196442450 | 0
would give in javascript
1074708816
and in ruby
89190868196442450
I fully understand the ruby behavior as Bitwise OR operator copies a bit if it exists in eather operand, but I'm still puzzled regarding the javascript behavior. I looked deeper in javascript integer representation and could not find a clear explanation. I found this, but did not fully get it.
89190868196442450 in binary is 100111100110111101001111101000000000011101100000101010010 which makes it 57 bits length.
Could anyone give me a clear explanation or the above result. And what operation should I do on the ruby code to ensure similar behavior?