Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re^3: Research into occasional participation in Perl/Raku development

by syphilis (Bishop)
on Oct 02, 2021 at 02:48 UTC ( #11137189=note: print w/replies, xml ) Need Help??

in reply to Re^2: Research into occasional participation in Perl/Raku development
in thread Research into occasional participation in Perl/Raku development

First up, I apologise for tainting this thread with that previous post of mine.
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.

I think it just depends on which tool you use to get the job done.

I see just 2 ways to compare rationals and doubles:
1) convert the rational to a double and compare the two doubles;
2) convert the double to a rational and compare the two rationals.

The former is probably the easier, and that's the approach that raku takes.
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.
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.
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.

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.
(Of course, perl has a core Math::BigRat module in which the overloading of comparision operators needed to be considered.)

  • Comment on Re^3: Research into occasional participation in Perl/Raku development

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11137189]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2021-12-02 00:11 GMT
Find Nodes?
    Voting Booth?
    R or B?

    Results (15 votes). Check out past polls.