Convert decimal number to rational: Difference between revisions

Content added Content deleted
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
(→‎{{header|Raku}}: Fix comment: Perl 6 --> Raku)
Line 2,145: Line 2,145:
=={{header|Raku}}==
=={{header|Raku}}==
(formerly Perl 6)
(formerly Perl 6)
Decimals are natively represented as rationals in Perl 6, so if the task does not need to handle repeating decimals, it is trivially handled by the <tt>.nude</tt> method, which returns the numerator and denominator:
Decimals are natively represented as rationals in Raku, so if the task does not need to handle repeating decimals, it is trivially handled by the <tt>.nude</tt> method, which returns the numerator and denominator:
<lang perl6>say .nude.join('/') for 0.9054054, 0.518518, 0.75;</lang>
<lang perl6>say .nude.join('/') for 0.9054054, 0.518518, 0.75;</lang>
{{out}}
{{out}}