| 1392 | |
| 1393 | template <typename Real> |
| 1394 | static Real ToRealPositiveNoSplit(const Decimal256& decimal, int32_t scale) { |
| 1395 | DCHECK_GE(decimal, 0); |
| 1396 | Real x = 0; |
| 1397 | const auto parts_le = bit_util::little_endian::Make(decimal.native_endian_array()); |
| 1398 | x += RealTraits<Real>::two_to_192(static_cast<Real>(parts_le[3])); |
| 1399 | x += RealTraits<Real>::two_to_128(static_cast<Real>(parts_le[2])); |
| 1400 | x += RealTraits<Real>::two_to_64(static_cast<Real>(parts_le[1])); |
| 1401 | x += static_cast<Real>(parts_le[0]); |
| 1402 | x *= LargePowerOfTen<Real>(-scale); |
| 1403 | return x; |
| 1404 | } |
| 1405 | |
| 1406 | /// An approximate conversion from Decimal256 to Real that guarantees: |
| 1407 | /// 1. If the decimal is an integer, the conversion is exact. |