Chapter 3 · July – September

Exact numbers, whole graphemes

Raku promises that 0.1 + 0.2 == 0.3 is True, because its decimals are exact rationals. It also counts a string's characters as a reader sees them, not as bytes or code points. Both promises are invisible until they are broken, and both were kept from the first commit. July was spent making them complete, and the rest of the time making them fast.

8,271Unicode collation conformance tests, all passing, from 11 July
100%of S15, Unicode: 91,752 of 91,752 assertions, v1.1.0
6.83 s → 0.32 sthe Mandelbrot demo, in one day of Rat work
865 → 7 msone big-integer reduction, after Knuth's algorithm D
The turnThe Unicode tables started at version 15.1 because that is what the host's Python shipped, and Python generated them. On 11 July the generator was rewritten in Raku and run by rakupp itself, and the tables went to Unicode 17.0. The engine now builds its own data.

Whole graphemes

Exact numbers

Underneath every arithmetic operation is a hand-written big integer, base 109 so that printing a number needs no conversion, with a fast path while it fits in 64 bits. A Rat is two of them. Raku also says when exactness ends: a Rat whose reduced denominator no longer fits in 64 bits becomes a Num, and FatRat never does. That rule arrived on 11 July with rat.t (869 tests) and complex.t (557) passing in full.

The Mandelbrot

examples/mandel.raku descends from the ASCII Mandelbrot that shipped with Parrot two decades ago. Its decimal literals are Rats, so the render is exact rational arithmetic, and it ran slower than Rakudo. One day's work on 11 July followed the profile:

The compiled binary took 0.12 s. The same maths, the same fractal, drawn in a blink.

Fast on other people's workloads

Division, according to the VM

On 13 September a module that calls the VM's own opcodes showed how they divide. nqp::div_i floors (-7 div 2 is −4), nqp::mod_i truncates (−1), and mod_I floors again. Raku++ had floored mod_i as well, and answered 0 on a zero divisor. No Roast file calls an nqp opcode, so nothing had noticed. All three now do what MoarVM does.