~ubuntu-branches/ubuntu/lucid/graphviz/lucid-security

« back to all changes in this revision

Viewing changes to tools/sfio/sfdlen.c

  • Committer: Bazaar Package Importer
  • Author(s): Stephen M Moraco
  • Date: 2002-02-05 18:52:12 UTC
  • Revision ID: james.westby@ubuntu.com-20020205185212-8i04c70te00rc40y
Tags: upstream-1.7.16
ImportĀ upstreamĀ versionĀ 1.7.16

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include        "sfhdr.h"
 
2
 
 
3
/*      Return the length of a double value if coded in a portable format
 
4
**
 
5
**      Written by Kiem-Phong Vo
 
6
*/
 
7
 
 
8
#if __STD_C
 
9
int _sfdlen(Sfdouble_t v)
 
10
#else
 
11
int _sfdlen(v)
 
12
Sfdouble_t      v;
 
13
#endif
 
14
{
 
15
#define N_ARRAY         (16*sizeof(Sfdouble_t))
 
16
        reg int         n, w;
 
17
        Sfdouble_t      x;
 
18
        int             exp;
 
19
 
 
20
        if(v < 0)
 
21
                v = -v;
 
22
 
 
23
        /* make the magnitude of v < 1 */
 
24
        if(v != 0.)
 
25
                v = frexp(v,&exp);
 
26
        else    exp = 0;
 
27
 
 
28
        for(w = 1; w <= N_ARRAY; ++w)
 
29
        {       /* get 2^SF_PRECIS precision at a time */
 
30
                n = (int)(x = ldexp(v,SF_PRECIS));
 
31
                v = x-n;
 
32
                if(v <= 0.)
 
33
                        break;
 
34
        }
 
35
 
 
36
        return 1 + sfulen(exp) + w;
 
37
}