[GRASS-git] [OSGeo/grass] c910e5: lib/gis: clarify intentional overflow in 48-bit LC...
Nicklas Larsson
noreply at github.com
Wed Oct 7 08:28:52 PDT 2026
Branch: refs/heads/main
Home: https://github.com/OSGeo/grass
Commit: c910e50c9fc2d6de54b62e3add69a0a9c9abdcd6
https://github.com/OSGeo/grass/commit/c910e50c9fc2d6de54b62e3add69a0a9c9abdcd6
Author: Nicklas Larsson <n_larsson at yahoo.com>
Date: 2026-10-07 (Wed, 07 Oct 2026)
Changed paths:
M lib/gis/lrand48.c
Log Message:
-----------
lib/gis: clarify intentional overflow in 48-bit LCG arithmetic (#8013)
Add `mul48()` to encapsulate multiplication modulo 2^48 and use it in
`lcg_step()` and `lcg_jump()`.
The multiplication may overflow `uint64_t` and wrap modulo 2^64. This is
intentional and does not affect the result modulo 2^48, since 2^48
divides 2^64. Consequently, masking the wrapped product to 48 bits gives
the same result as computing the full product modulo 2^48.
Centralising the operation in `mul48()` makes this property explicit and
avoids repeating potentially misleading unsigned multiplication
throughout the LCG implementation. It also provides a single location
for documenting or suppressing static-analysis warnings about the
intentional wraparound which is used for Coverity Scan now.
To unsubscribe from these emails, change your notification settings at https://github.com/OSGeo/grass/settings/notifications
More information about the grass-commit
mailing list