From 3d5ff2c8a214d88cf66d4a8ae56dc39ea629e84b Mon Sep 17 00:00:00 2001 From: Ed Hennis Date: Wed, 25 Feb 2026 21:10:11 -0400 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/libxrpl/basics/Number.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libxrpl/basics/Number.cpp b/src/libxrpl/basics/Number.cpp index 61c2398dd8..673f7439a0 100644 --- a/src/libxrpl/basics/Number.cpp +++ b/src/libxrpl/basics/Number.cpp @@ -314,8 +314,10 @@ Number::externalToInternal(rep mantissa) if (mantissa >= 0) return mantissa; - // Cast to unsigned before negating to avoid undefined behavior - // when v == INT64_MIN (negating INT64_MIN in signed is UB) + // Cast to unsigned before negating to avoid undefined behavior when + // mantissa == std::numeric_limits::min() (INT64_MIN). Negating + // INT64_MIN in signed arithmetic is UB, but casting to the unsigned + // internalrep first makes the operation well-defined. return -static_cast(mantissa); }