Skip to content

Creating an arbitrary precision rational with negative denominator throws exception #27

@Schniwarixl

Description

@Schniwarixl

When using a rational with an arbitrary precision integer as given by...

typedef boost::multiprecision::number<boost::multiprecision::cpp_int_backend<0, 0, boost::multiprecision::signed_magnitude, boost::multiprecision::checked>> RationalIntType;

typedef boost::rational Rational;

The following will throw an exception...

Rational test(-2, -4);

This is due to the line

if (den < -(std::numeric_limits::max)()) {
BOOST_THROW_EXCEPTION(bad_rational("bad rational: non-zero singular denominator"));
}

in "template void rational::normalize()"

where std::numeric_limits::max() gives 0. Therefore all negative denominators will throw an exception.

In previous boost version there was no test against max().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions