File indexing completed on 2025-04-19 08:19:39
0001
0002
0003
0004
0005 #ifndef BOOST_CHARCONV_DETAIL_COMPUTE_FLOAT32_HPP
0006 #define BOOST_CHARCONV_DETAIL_COMPUTE_FLOAT32_HPP
0007
0008 #include <boost/charconv/detail/compute_float64.hpp>
0009 #include <limits>
0010 #include <cstdint>
0011 #include <cmath>
0012
0013 namespace boost { namespace charconv { namespace detail {
0014
0015 inline float compute_float32(std::int64_t power, std::uint64_t i, bool negative, bool& success) noexcept
0016 {
0017 const double d = compute_float64(power, i, negative, success);
0018 float return_val;
0019
0020 if (success)
0021 {
0022
0023
0024
0025
0026
0027 if (d > static_cast<double>((std::numeric_limits<float>::max)()) ||
0028 d < static_cast<double>((std::numeric_limits<float>::lowest)()))
0029 {
0030 return_val = negative ? -HUGE_VALF : HUGE_VALF;
0031 success = false;
0032 }
0033 else
0034 {
0035 return_val = static_cast<float>(d);
0036 }
0037 }
0038 else
0039 {
0040 if (power > 38)
0041 {
0042 return_val = negative ? -HUGE_VALF : HUGE_VALF;
0043 }
0044 else
0045 {
0046 return_val = negative ? -0.0F : 0.0F;
0047 }
0048 }
0049
0050 return return_val;
0051 }
0052
0053 }}}
0054
0055 #endif