I build a class mapping rational number, and i'd like to implement the multiplication by a scalar operation overflow, something like that :
Rational &operator*(Rational const& a, double lambda)
{
Rational r(a._num * lambda, a._den);
}
Where _num
and _den
are the numerator and denominator of the rational number.
When I run cout << r * 45.2;
, I get -858993460/4389064
. It should be noted that the operator<<
is working fine on others instances of Rational
.
How can it's not be working? Thanks :)