#include <stdio.h>

char *get_number_formatted(double f)
{
    static char buf[128]; // this function is not thread-safe
    int i, j;

    i = snprintf(buf, 128, "%20.10f", f) - 2;

    for (j = i - 8; i > j; --i)
        if (buf[i] != '0')
            break;

    buf[i + 1] = '\0';
    return buf;
}

int main(void)
{
	int i;
	for (i = -4; i < 5; ++i)
        printf("%5d %s\n", i, get_number_formatted(pow(10.0, i)));
    return 0;
}