diff --git a/Improving-performance-with-Viper-code.md b/Improving-performance-with-Viper-code.md index 95f8a40..1f32d9b 100644 --- a/Improving-performance-with-Viper-code.md +++ b/Improving-performance-with-Viper-code.md @@ -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