From 90613a34bfe5a3e863306ce4edcaaa9ff1985a60 Mon Sep 17 00:00:00 2001 From: bixb922 <70152274+bixb922@users.noreply.github.com> Date: Thu, 2 May 2024 09:29:57 -0400 Subject: [PATCH] Unary minus is being developed in version 1.23 --- Improving-performance-with-Viper-code.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Improving-performance-with-Viper-code.md b/Improving-performance-with-Viper-code.md index 1f32d9b..d731b58 100644 --- a/Improving-performance-with-Viper-code.md +++ b/Improving-performance-with-Viper-code.md @@ -234,6 +234,7 @@ 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```. +In versions MicroPython 1.22 and prior, unary minus is not implemented, instead of `x=-a` use `x=0-a`. In version 1.23 the unary minus is being implemented, but not completely yet. 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.