add two small integers, checking for overflow. we want an efficient operation. for msvc, where we don't have built-in intrinsics, this is still pretty fast.
| 3609 | // we don't have built-in intrinsics, this is still |
| 3610 | // pretty fast. |
| 3611 | fastfloat_really_inline FASTFLOAT_CONSTEXPR20 limb |
| 3612 | scalar_add(limb x, limb y, bool &overflow) noexcept { |
| 3613 | limb z; |
| 3614 | // gcc and clang |
| 3615 | #if defined(__has_builtin) |
| 3616 | #if __has_builtin(__builtin_add_overflow) |
| 3617 | if (!cpp20_and_in_constexpr()) { |
| 3618 | overflow = __builtin_add_overflow(x, y, &z); |
| 3619 | return z; |
| 3620 | } |
| 3621 | #endif |
| 3622 | #endif |
| 3623 | |
| 3624 | // generic, this still optimizes correctly on MSVC. |
| 3625 | z = x + y; |
| 3626 | overflow = z < x; |
| 3627 | return z; |
| 3628 | } |
| 3629 | |
| 3630 | // multiply two small integers, getting both the high and low bits. |
| 3631 | fastfloat_really_inline FASTFLOAT_CONSTEXPR20 limb |
no test coverage detected