12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #ifndef BOOST_CHARCONV_DETAIL_COMPUTE_FLOAT32_HPP
- #define BOOST_CHARCONV_DETAIL_COMPUTE_FLOAT32_HPP
- #include <boost/charconv/detail/compute_float64.hpp>
- #include <limits>
- #include <cstdint>
- #include <cmath>
- namespace boost { namespace charconv { namespace detail {
- inline float compute_float32(std::int64_t power, std::uint64_t i, bool negative, bool& success) noexcept
- {
- const double d = compute_float64(power, i, negative, success);
- float return_val;
- if (success)
- {
-
-
-
-
-
- if (d > static_cast<double>((std::numeric_limits<float>::max)()) ||
- d < static_cast<double>((std::numeric_limits<float>::lowest)()))
- {
- return_val = negative ? -HUGE_VALF : HUGE_VALF;
- success = false;
- }
- else
- {
- return_val = static_cast<float>(d);
- }
- }
- else
- {
- if (power > 38)
- {
- return_val = negative ? -HUGE_VALF : HUGE_VALF;
- }
- else
- {
- return_val = negative ? -0.0F : 0.0F;
- }
- }
- return return_val;
- }
- }}}
- #endif
|