#!/usr/bin/env /friends/.rakudobrew/bin/perl6 use v6; my Num $finish = Num(@*ARGS ?? @*ARGS[0] !! 2.0); die if +$finish == 0; my Str $format = '%.17g'; my Num $d = $finish / 2; my Num $f = $d; for 0..53 { my Str $s = ~$d; die "Round trip failed for {$d}: off by {+$s - $d}" if +$s != $d; say sprintf "%s = 0x%sp0", $s, $d.base(16,16); last if $d == $finish; $f /= 2, $d += $f }