File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2828#include " Dispatcher.h"
2929#include " ThreadPool.h"
3030
31+ // This number is the maximum integer that can be represented exactly as a double
32+ #define MAX_SAFE_INTEGER uint64_t (9007199254740991 )
33+
3134#if __has_include(<cxxabi.h>)
3235#include < cxxabi.h>
3336#endif
@@ -122,7 +125,7 @@ template <> struct JSIConverter<uint64_t> {
122125 static uint64_t fromJSI (jsi::Runtime& runtime, const jsi::Value& arg, bool outOfBound) {
123126 if (arg.isNumber ()) {
124127 double value = arg.asNumber ();
125- if (value < 0 || value > static_cast < double >(std::numeric_limits< uint64_t >:: max ()) ) {
128+ if (value < 0 || value > MAX_SAFE_INTEGER ) {
126129 throw jsi::JSError (runtime, " Number out of range for uint64_t" );
127130 }
128131 return static_cast <uint64_t >(value);
@@ -132,7 +135,7 @@ template <> struct JSIConverter<uint64_t> {
132135 }
133136
134137 static jsi::Value toJSI (jsi::Runtime& runtime, uint64_t arg) {
135- if (arg <= static_cast < uint64_t >(std::numeric_limits< double >:: max ()) ) {
138+ if (arg <= MAX_SAFE_INTEGER ) {
136139 return jsi::Value (static_cast <double >(arg));
137140 } else {
138141 throw jsi::JSError (runtime, " Number too large to be represented as a double" );
You can’t perform that action at this time.
0 commit comments