note
syphilis
First up, I apologise for tainting this thread with that previous post of mine.
<br>I need to keep in mind that raku was not written for me, but written for a group of people who find that raku suits them, and who are quite happy with what raku provides - and that I have no business complaining about anything that raku does.
<br><br><I>I think it just depends on which tool you use to get the job done.</I><br><br>
I see just 2 ways to compare rationals and doubles:
<br>1) convert the rational to a double and compare the two doubles;
<br>or
<br>2) convert the double to a rational and compare the two rationals.
<br><br> The former is probably the easier, and that's the approach that raku takes.
<br>But, in converting a rational to a double, it is often the case that precision is lost, and the double thus obtained is merely an approximation of the rational value from which it was derived.
<br>OTOH, every finite double can be represented exactly as a rational - and it therefore makes sense to me that they should be compared via the latter option (like python3 does), as we are then always comparing exact values.
<br>There's a caveat here in that the numerators/denominators needed to express some doubles can be rather large, and this could be viewed as a dis-incentive to using this second option.
<br><br>Perl doesn't have a rational scalar, and C doesn't have a rational data type, so neither of those languages have needed to think about how rationals and floats should be compared.
<br>(Of course, perl has a core Math::BigRat module in which the overloading of comparision operators needed to be considered.)
<br><br>Cheers,<br>Rob
11137153
11137187