#! /usr/bin/perl

use strict;
use warnings;

my $n = 1;  # numerator
my $d = 10; # denominator

my $maxstep = 20;

my $s = 0; # current step

print int($n/$d),".";

my $b = 2; # the base of the target number system

while( $n != 0 && $s < $maxstep ) {
    $n *= $b;
    print int($n/$d); #  |_ b*(n/d) _|
    $n %= $d;         #  b*(n/d) - |_ b*(n/d) _|
    $s++;
    print " " if $s % 4 == 0; # print space after each 4 digits
}

print "\n";
