4 ms·
> If anybody knows how similar calculations can be easily achieved in JS for example Simply "a = (a + 0x1234) & 0xffffffff;". Or whatever width you require, 0x
by vardump 4y ago
> If anybody knows how similar calculations can be easily achieved in JS for example
Simply "a = (a + 0x1234) & 0xffffffff;". Or whatever width you require, 0xff or 0xffff. JIT is going to optimize that and-operation away (at least for 32-bit mask 0xffffffff) and keep the integer value internally.
You can also "cast" a var to int by "ORring" 0 with it, like "a |= 0;"
- flowerbreeze 4y agoThank you! This does exactly what I meant. I think this is the best solution for my use-cases. It even handles floating point operations to a correctly, something I didn't expect.