Hacker News new | ask | show | jobs
by jwmerrill 1220 days ago
Raku interprets decimal literals (like 0.1) as limited-precision rational numbers (Rats) [0-1].

I think this is a pretty user-friendly compromise.

[0] https://docs.raku.org/syntax/Number%20literals

[1] https://docs.raku.org/type/Rat

1 comments

Actually, the limited precision is the default (caused by the numerator as well as the denominator having to fit in a 64-bit integer).

By default, when it not longer fits, it will convert to floating point (called Num in Raku). But this behaviour can be set: another alternative is for the numerator and denominator both being big integers. This gives you infinite precision rational numbers, at the expense of potentially needing infinite CPU and/or RAM.