| 356 | |
| 357 | template <typename Real> |
| 358 | static Result<Decimal64> FromPositiveRealApprox(Real real, int32_t precision, |
| 359 | int32_t scale) { |
| 360 | const auto x = std::nearbyint(real * PowerOfTen<Real>(scale)); |
| 361 | const auto max_abs = PowerOfTen<Real>(precision); |
| 362 | if (x <= -max_abs || x >= max_abs) { |
| 363 | return OverflowError(real, precision, scale); |
| 364 | } |
| 365 | |
| 366 | return Decimal64(static_cast<int64_t>(x)); |
| 367 | } |
| 368 | |
| 369 | template <typename Real> |
| 370 | static Real ToRealPositiveNoSplit(const Decimal64& decimal, int32_t scale) { |
nothing calls this directly
no test coverage detected