Skip to content

saturating_mul inconsistent #479

Description

@mborland
  1. saturating_mul wrong branch

Disclaimer: Not a math guy, but from my understanding:

saturating_mul(a, b); // == a * b, whenever a * b fits
saturating_mul(a, b); // == BOOST_INT128_UINT128_MAX, otherwise
Demo: https://godbolt.org/z/Y6TW9458e

constexpr auto value = boost::int128::uint128_t{1} << 127;
static_assert(BOOST_INT128_UINT128_MAX == boost::int128::saturating_mul(value, boost::int128::uint128_t{1}));
// expected: BOOST_INT128_UINT128_MAX == value

Metadata

Metadata

Assignees

Labels

Boost ReviewFeedback from the review period including pre- and post- on the MLBugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions