| 968 | } |
| 969 | |
| 970 | bool decimal_to_float32(const Decimal &decimal, bool negative_zero, |
| 971 | float &out) { |
| 972 | std::string text; |
| 973 | if (!decimal_plain_string(decimal, text)) { |
| 974 | return false; |
| 975 | } |
| 976 | out = std::strtof(text.c_str(), nullptr); |
| 977 | if (negative_zero && decimal.is_zero()) { |
| 978 | out = -0.0f; |
| 979 | } |
| 980 | if (!std::isfinite(out)) { |
| 981 | return false; |
| 982 | } |
| 983 | Decimal actual; |
| 984 | return decimal_from_float32(out, actual) && |
| 985 | decimal_equal_value(decimal, actual); |
| 986 | } |
| 987 | |
| 988 | bool decimal_to_float64(const Decimal &decimal, bool negative_zero, |
| 989 | double &out) { |
no test coverage detected