]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
libvex_ir.h: Clarify semantics of division and modulo operation.
authorFlorian Krohm <flo2030@eich-krohm.de>
Sat, 30 Aug 2025 13:39:04 +0000 (13:39 +0000)
committerFlorian Krohm <flo2030@eich-krohm.de>
Sat, 30 Aug 2025 13:39:04 +0000 (13:39 +0000)
VEX/pub/libvex_ir.h

index 750ba0701870bc793fde2eb2d8d6b9c7f2463941..8c68fab4413807ece4710ded9502ea1f1910b450 100644 (file)
@@ -492,7 +492,13 @@ typedef
       Iop_CmpORD32S, Iop_CmpORD64S,
 
       /* Division */
-      /* TODO: clarify semantics wrt rounding, negative values, whatever */
+      /* Semantics of division as per C standard:
+         If the value of the divisor is zero, the behaviour is undefined.
+         When integers are divided, the result of division is the algebraic
+         quotient with any fractional part discarded. In other words:
+         truncation towards zero. If the quotient a/b is representable,
+         the expression (a/b)*b + a%b shall equal a; otherwise, the behaviour
+         of division and modulo operation is undefined. */
       Iop_DivU32,   // :: I32,I32 -> I32 (simple div, no mod)
       Iop_DivS32,   // ditto, signed
       Iop_DivU64,   // :: I64,I64 -> I64 (simple div, no mod)