File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -38,16 +38,19 @@ uint64_t NumberCast<uint64_t>(const Napi::Number& num) {
3838 return 0 ;
3939 }
4040
41- if (value > static_cast <double >((1ULL << 53 ) - 1 )) {
41+ static constexpr auto max_safe_integer = static_cast <double >((1ULL << 53 ) - 1 );
42+ if (value > max_safe_integer) {
4243 Warn (num.Env (),
4344 " Value is larger than Number.MAX_SAFE_INTEGER and may have been rounded "
4445 " inaccurately." );
4546 }
4647
4748 /* If the next representable value of the double is beyond the maximum
4849 integer, then assume the maximum integer. */
50+ static constexpr auto max_uint64_as_double =
51+ static_cast <double >(std::numeric_limits<uint64_t >::max ());
4952 if (std::nextafter (value, std::numeric_limits<double >::infinity ())
50- > std::numeric_limits< uint64_t >:: max () ) {
53+ > max_uint64_as_double ) {
5154 return std::numeric_limits<uint64_t >::max ();
5255 }
5356
You can’t perform that action at this time.
0 commit comments