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

double frexp10( double x, int * exp )
{
    double tmp = .0 > x ? -x : x;
    *exp = 0;
    
    if( x == .0 )
        return x;
    
    if( tmp >= 10. ) {
        
        *exp = 1;
        for( ; !( ( tmp /= 10. ) < 10. ); ++( *exp ) );
    
    } else if( ! ( tmp >= 1. ) ) {
        
        *exp = -1;
        for( ; !( ( tmp *= 10. ) > 1. ); --( *exp) );
    }

    return .0 > x ? -tmp : tmp;
}

int main( void )
{
    double input = 1234567890;
    double result = .0;
    int exp = 0;
    int i = 0;
    
    for( ; i < 16; input /= 10, ++i ) {
        
        printf( "input = %20lf   ", input );
        result = frexp10( input, &exp );
        printf( "result = %011.10lf x 10^%d\n", result, exp );    
    }
    
    return EXIT_SUCCESS;
}
