Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char* format(char* x)
- {
- int e;
- char z[64], s[64];
- if(x[0] == '-') {
- x = x + 1;
- z[0] = '-';
- }
- while(x[0] = '0')
- x = x + 1;
- while(x[e] != '.')
- e++;
- if(e == 0)
- {
- while(x[1] == '0')
- {
- e--;
- memmove (x+1, x+2, strlen (x+2));
- }
- }
- memmove(x + 1 + e, x + 2 + e, strlen(x + 2 + e));
- e--;
- memmove(x + 2, x + 3, strlen(x + 2));
- x[1] = '.';
- x[6] = 0;
- while(strlen(x) < 4)
- strcat(x, "0");
- itoa(e, s, 64);
- char *result = new char[64];
- memset(result, 0, 64);
- memcpy(result, z, strlen(z));
- strcat(result, x);
- strcat(result, "E");
- strcat(result, s);
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement