From b724617a8d91301d8ee3b5cb064b4bb6841bf779 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Fri, 30 May 2025 18:08:32 +0100 Subject: [PATCH] Revert "Optimise the maths for the jsonrpc oversize integer workaround". This reverts commit 937404e3118f10735875ff45a658facbf77e984d. --- modules/rpc/jsonrpc.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/rpc/jsonrpc.cpp b/modules/rpc/jsonrpc.cpp index dfb6ce2e5..f39f01cb5 100644 --- a/modules/rpc/jsonrpc.cpp +++ b/modules/rpc/jsonrpc.cpp @@ -239,7 +239,8 @@ yyjson_mut_val *JSONRPCServiceInterface::SerializeElement(yyjson_mut_doc *doc, c }, [&doc, &elem](int64_t i) { - if (std::abs(i) < (1LL << integer_bits)) + auto bits = std::floor(std::log2(abs(i))) + 1; + if (bits <= integer_bits) { // We can fit this into an integer. elem = yyjson_mut_int(doc, i); @@ -253,7 +254,8 @@ yyjson_mut_val *JSONRPCServiceInterface::SerializeElement(yyjson_mut_doc *doc, c }, [&doc, &elem](uint64_t u) { - if (u < (1ULL << integer_bits)) + auto bits = std::floor(std::log2(u)) + 1; + if (bits <= integer_bits) { // We can fit this into an integer. elem = yyjson_mut_uint(doc, u);