| 289 | |
| 290 | template <typename Real> |
| 291 | static Result<Decimal32> FromPositiveRealApprox(Real real, int32_t precision, |
| 292 | int32_t scale) { |
| 293 | const auto x = std::nearbyint(real * PowerOfTen<Real>(scale)); |
| 294 | const auto max_abs = PowerOfTen<Real>(precision); |
| 295 | if (x <= -max_abs || x >= max_abs) { |
| 296 | return OverflowError(real, precision, scale); |
| 297 | } |
| 298 | |
| 299 | return Decimal32(static_cast<int32_t>(x)); |
| 300 | } |
| 301 | |
| 302 | template <typename Real> |
| 303 | static Real ToRealPositiveNoSplit(const Decimal32& decimal, int32_t scale) { |
nothing calls this directly
no test coverage detected