You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It appears this has been a problem since 1.78.0, and is still affecting the current version of multiprecision.
Attempting to construct a cpp_rational with a rational value of 1 divided by a cpp_int value of anything else results in the final value being 1, instead of the correct value.
This can be worked-around by ensuring that the divided-by value is explicitly cast to a cpp_rational type before performing the division.
Curiously, this only occurs if the Numerator is 1; if the Numerator is any other value, the rational is correctly initialized.
In 1.78.0 the rational adapter was changed here. This looks to be similar to #541 where implicit conversions were dropped by the change. @jzmaddock would know best.
It appears this has been a problem since 1.78.0, and is still affecting the current version of multiprecision.
Attempting to construct a
cpp_rational
with a rational value of 1 divided by acpp_int
value of anything else results in the final value being 1, instead of the correct value.This can be worked-around by ensuring that the divided-by value is explicitly cast to a
cpp_rational
type before performing the division.Curiously, this only occurs if the Numerator is 1; if the Numerator is any other value, the rational is correctly initialized.
Godbolt Link demonstrating that the behavior was different (correct) in 1.77.0 and persists up through 1.81.0
Sample Code to reproduce the issue:
Output in 1.77.0:
Output in 1.81.0:
The text was updated successfully, but these errors were encountered: