#include <stdio.h>
#include <stdlib.h>

int main( int argc, char *argv[] )
{
    int n = 1;  // numerator
    int d = 10; // denominator
    int b = 2;  // the base of the target number system
    int s = 0;  // current step
    int maxstep = 20;

    /* Get the max. digit count: */
    if( argc > 1 ) {
        maxstep = atoi( argv[1] );
    }
    
    printf( "%d.", n/d );
    while( n != 0 && s < maxstep ) {
        n *= b;
        printf( "%d", n/d ); //  |_ b*(n/d) _|
        n %= d;              //  b*(n/d) - |_ b*(n/d) _|
        s++;
        if( s % 4 == 0 ) {
            printf( " " );   // print space after each 4 digits
        }
    }
    printf( "\n" );

    return 0;
}
