Fix type identifiers for RationalNumberType

This commit is contained in:
Alex Beregszaszi
2018-08-07 13:23:14 +01:00
parent 9d3827266c
commit b0f9fc5af0
3 changed files with 12 additions and 1 deletions
+8 -1
View File
@@ -1146,7 +1146,14 @@ TypePointer RationalNumberType::binaryOperatorResult(Token::Value _operator, Typ
string RationalNumberType::richIdentifier() const
{
return "t_rational_" + m_value.numerator().str() + "_by_" + m_value.denominator().str();
// rational seemingly will put the sign always on the numerator,
// but let just make it deterministic here.
bigint numerator = abs(m_value.numerator());
bigint denominator = abs(m_value.denominator());
if (m_value < 0)
return "t_rational_minus_" + numerator.str() + "_by_" + denominator.str();
else
return "t_rational_" + numerator.str() + "_by_" + denominator.str();
}
bool RationalNumberType::operator==(Type const& _other) const