Document shifting by negative values. Document XTENSAWIN behavior when shifting left by large numbers

master
bixb922 2024-04-20 14:13:28 -04:00
rodzic e0923f5a2b
commit 12dfabab39
1 zmienionych plików z 2 dodań i 2 usunięć

@ -235,9 +235,9 @@ A viper ```int``` is not an object, and thus does not support methods such as ``
The \*\* operator (exponentiation, `__pow__`) is not implemented for viper ```int```.
Be aware: Do not shift left or right by a negative value, i.e. `x<<(-1)` or `x>>(-1)` should not be used because the result is undefined. This mirrors the C language definition for shift. Unlike regular MicroPython, there is no check for negative shift amounts.
Be aware: Do not use shift left or right with a negative value, i.e. `x<<(-1)` or `x>>(-1)` should not be used because the result is undefined. This mirrors the C language definition for shifting. Unlike regular MicroPython, there is no check (no exception raised) for negative shift amounts.
Be aware: If you are using a ESP32 or ESP32-S3 (or any XTENSAWIN processor, in MicroPython parlance), do not shift left by more than 31 bits. The result should be zero, but isn't. The RP2040 is not affected. Not tested yet for other processors. The workaround is to test if the shift amount is larger than 31 before shifting.
Be aware: If you are using a ESP32 or ESP32-S3 (or any XTENSAWIN processor, in MicroPython parlance), do not shift left by more than 31 bits. The result should be zero, but isn't. The RP2040 is not affected. Not tested yet for other processors. The workaround is to check if the shift amount is larger than 31 before shifting.
### int() casting