Skip to content

Commit

Permalink
explicit cast
Browse files Browse the repository at this point in the history
  • Loading branch information
lemire committed Jan 28, 2024
1 parent 9da74ca commit eb584f7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/fast_float/ascii_number.h
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,8 @@ from_chars_result_t<UC> parse_int_string(UC const* p, UC const* pend, T& value,
// this weird workaround is required because:
// - converting unsigned to signed when its value is greater than signed max is UB pre-C++23.
// - reinterpret_casting (~i + 1) would work, but it is not constexpr
// this is always optimized into a neg instruction.
value = T(-std::numeric_limits<T>::max() - T(i - std::numeric_limits<T>::max()));
// this is always optimized into a neg instruction (note: T is an integer type)
value = T(-std::numeric_limits<T>::max() - T(i - uint64_t(std::numeric_limits<T>::max())));
#ifdef FASTFLOAT_VISUAL_STUDIO
#pragma warning(pop)
#endif
Expand Down

0 comments on commit eb584f7

Please sign in to comment.