~ubuntu-branches/ubuntu/trusty/musl/trusty-proposed

« back to all changes in this revision

Viewing changes to src/stdlib/ecvt.c

  • Committer: Package Import Robot
  • Author(s): Kevin Bortis
  • Date: 2013-09-20 20:54:14 UTC
  • Revision ID: package-import@ubuntu.com-20130920205414-5b61trtmma18w58o
Tags: upstream-0.9.13
ImportĀ upstreamĀ versionĀ 0.9.13

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdlib.h>
 
2
#include <stdio.h>
 
3
 
 
4
char *ecvt(double x, int n, int *dp, int *sign)
 
5
{
 
6
        static char buf[16];
 
7
        char tmp[32];
 
8
        int i, j;
 
9
 
 
10
        if (n-1U > 15) n = 15;
 
11
        sprintf(tmp, "%.*e", n-1, x);
 
12
        i = *sign = (tmp[0]=='-');
 
13
        for (j=0; tmp[i]!='e'; j+=(tmp[i++]!='.'))
 
14
                buf[j] = tmp[i];
 
15
        buf[j] = 0;
 
16
        *dp = atoi(tmp+i+1)+1;
 
17
 
 
18
        return buf;
 
19
}