summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/modules.example.conf4
-rw-r--r--modules/rpc/jsonrpc.cpp6
2 files changed, 4 insertions, 6 deletions
diff --git a/data/modules.example.conf b/data/modules.example.conf
index 93aa0df54..b6c86871d 100644
--- a/data/modules.example.conf
+++ b/data/modules.example.conf
@@ -814,14 +814,14 @@ module
* The maximum number of bits an integer can be have in its native type.
*
* By default Anope will emit integers as their native JSON type. If you are
- * using JavaScript (which has 56 bit integers) or another language with
+ * using JavaScript (which has 53 bit integers) or another language with
* native integer types smaller than 64 bits you may need to limit the size
* of integers emitted by Anope.
*
* If this is enabled a string will be used for values outside of the range
* supported by the native data type.
*/
- #integer_bits = 56
+ #integer_bits = 53
/* Web service to use. Requires httpd. */
server = "httpd/main"
diff --git a/modules/rpc/jsonrpc.cpp b/modules/rpc/jsonrpc.cpp
index 189e2b3a8..2e8753b8a 100644
--- a/modules/rpc/jsonrpc.cpp
+++ b/modules/rpc/jsonrpc.cpp
@@ -239,8 +239,7 @@ yyjson_mut_val *JSONRPCServiceInterface::SerializeElement(yyjson_mut_doc *doc, c
},
[&doc, &elem](int64_t i)
{
- auto bits = std::floor(std::log2(abs(i))) + 1;
- if (bits <= integer_bits)
+ if (std::abs(i) < (1LL << integer_bits))
{
// We can fit this into an integer.
elem = yyjson_mut_int(doc, i);
@@ -254,8 +253,7 @@ yyjson_mut_val *JSONRPCServiceInterface::SerializeElement(yyjson_mut_doc *doc, c
},
[&doc, &elem](uint64_t u)
{
- auto bits = std::floor(std::log2(u)) + 1;
- if (bits <= integer_bits)
+ if (u < (1ULL << integer_bits))
{
// We can fit this into an integer.
elem = yyjson_mut_uint(doc, u);