mux/src/strtod.cpp File Reference

#include "autoconf.h"
#include "config.h"
#include "externs.h"
#include "stringutil.h"
#include "float.h"
#include "math.h"

Include dependency graph for strtod.cpp:

Go to the source code of this file.

Data Structures

union  U
struct  Bigint

Defines

#define IEEE_8087
#define Long   INT32
#define PRIVATE_MEM   2304
#define PRIVATE_mem   ((PRIVATE_MEM+sizeof(double)-1)/sizeof(double))
#define IEEE_Arith
#define CONST   const
#define word0(x)   ((U*)&x)->L[1]
#define word1(x)   ((U*)&x)->L[0]
#define dval(x)   ((U*)&x)->d
#define Storeinc(a, b, c)
#define Exp_shift   20
#define Exp_shift1   20
#define Exp_msk1   0x100000
#define Exp_msk11   0x100000
#define Exp_mask   0x7ff00000
#define P   53
#define Bias   1023
#define Emin   (-1022)
#define Exp_1   0x3ff00000
#define Exp_11   0x3ff00000
#define Ebits   11
#define Frac_mask   0xfffff
#define Frac_mask1   0xfffff
#define Ten_pmax   22
#define Bletch   0x10
#define Bndry_mask   0xfffff
#define Bndry_mask1   0xfffff
#define LSB   1
#define Sign_bit   0x80000000
#define Log2P   1
#define Tiny0   0
#define Tiny1   1
#define Quick_max   14
#define Int_max   14
#define Avoid_Underflow
#define Flt_Rounds   1
#define Rounding   Flt_Rounds
#define rounded_product(a, b)   a *= b
#define rounded_quotient(a, b)   a /= b
#define Big0   (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1))
#define Big1   0xffffffff
#define FFFFFFFF   0xffffffffUL
#define Llong   INT64
#define ULLong   UINT64
#define Kmax   15
#define Bcopy(x, y)
#define d0   word0(d)
#define d1   word1(d)
#define d0   word0(d)
#define d1   word1(d)
#define Scale_Bit   0x10
#define n_bigtens   5

Typedefs

typedef UINT32 ULong
typedef Bigint Bigint

Functions

static BigintBalloc (int k)
static void Bfree (Bigint *v)
static Bigintmultadd (Bigint *b, int m, int a)
static Bigints2b (CONST char *s, int nd0, int nd, ULong y9)
static int hi0bits (register ULong x)
static int lo0bits (ULong *y)
static Biginti2b (int i)
static Bigintmult (Bigint *a, Bigint *b)
static Bigintpow5mult (Bigint *b, int k)
static Bigintlshift (Bigint *b, int k)
static int cmp (Bigint *a, Bigint *b)
static Bigintdiff (Bigint *a, Bigint *b)
double ulp (double x)
static double b2d (Bigint *a, int *e)
static Bigintd2b (double d, int *e, int *bits)
static double ratio (Bigint *a, Bigint *b)
double mux_strtod (CONST char *s00, char **se)
static int quorem (Bigint *b, Bigint *S)
static char * rv_alloc (unsigned int i)
static char * nrv_alloc (char *s, char **rve, int n)
static void freedtoa (char *s)
char * mux_dtoa (double d, int mode, int ndigits, int *decpt, int *sign, char **rve)
void mux_FPInit (void)
void mux_FPSet (void)
void mux_FPRestore (void)
void FLOAT_Initialize (void)

Variables

static double private_mem [PRIVATE_mem]
static double * pmem_next = private_mem
static Bigintfreelist [Kmax+1]
static Bigintp5s
static CONST double tens []
static CONST double bigtens [] = { 1e16, 1e32, 1e64, 1e128, 1e256 }
static CONST double tinytens []
static char * dtoa_result


Define Documentation

#define Avoid_Underflow

Definition at line 287 of file strtod.cpp.

Referenced by mux_strtod().

#define Bcopy ( x,
 ) 

Value:

memcpy((char *)&x->sign, (char *)&y->sign, \
y->wds*sizeof(Long) + 2*sizeof(int))

Definition at line 460 of file strtod.cpp.

Referenced by multadd(), mux_dtoa(), and mux_strtod().

#define Bias   1023

Definition at line 268 of file strtod.cpp.

Referenced by d2b(), mux_dtoa(), and mux_strtod().

#define Big0   (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1))

Definition at line 383 of file strtod.cpp.

Referenced by mux_strtod().

#define Big1   0xffffffff

Definition at line 384 of file strtod.cpp.

Referenced by mux_strtod().

#define Bletch   0x10

Definition at line 276 of file strtod.cpp.

Referenced by mux_dtoa().

#define Bndry_mask   0xfffff

Definition at line 277 of file strtod.cpp.

Referenced by mux_dtoa(), and mux_strtod().

#define Bndry_mask1   0xfffff

Definition at line 278 of file strtod.cpp.

Referenced by mux_strtod().

#define CONST   const

Definition at line 210 of file strtod.cpp.

Referenced by mux_strtod().

#define d0   word0(d)

#define d0   word0(d)

Referenced by b2d(), d2b(), GregorianFromFixed(), and LinearTimeToFieldedTime().

#define d1   word1(d)

#define d1   word1(d)

Referenced by b2d(), check_idle(), d2b(), GregorianFromFixed(), match_possessed(), and shovechars().

#define dval (  )     ((U*)&x)->d

Definition at line 240 of file strtod.cpp.

Referenced by b2d(), mux_dtoa(), mux_strtod(), ratio(), and ulp().

#define Ebits   11

Definition at line 272 of file strtod.cpp.

Referenced by b2d().

#define Emin   (-1022)

Definition at line 269 of file strtod.cpp.

Referenced by mux_strtod().

#define Exp_1   0x3ff00000

Definition at line 270 of file strtod.cpp.

Referenced by b2d(), and mux_strtod().

#define Exp_11   0x3ff00000

Definition at line 271 of file strtod.cpp.

Referenced by mux_dtoa().

#define Exp_mask   0x7ff00000

Definition at line 266 of file strtod.cpp.

Referenced by mux_dtoa(), mux_strtod(), and ulp().

#define Exp_msk1   0x100000

Definition at line 264 of file strtod.cpp.

Referenced by d2b(), mux_dtoa(), mux_strtod(), ratio(), and ulp().

#define Exp_msk11   0x100000

Definition at line 265 of file strtod.cpp.

Referenced by d2b().

#define Exp_shift   20

Definition at line 262 of file strtod.cpp.

Referenced by d2b(), mux_strtod(), and ulp().

#define Exp_shift1   20

Definition at line 263 of file strtod.cpp.

Referenced by mux_dtoa().

#define FFFFFFFF   0xffffffffUL

Definition at line 390 of file strtod.cpp.

Referenced by quorem().

#define Flt_Rounds   1

Definition at line 297 of file strtod.cpp.

Referenced by mux_dtoa(), and mux_strtod().

#define Frac_mask   0xfffff

Definition at line 273 of file strtod.cpp.

Referenced by d2b(), mux_dtoa(), and mux_strtod().

#define Frac_mask1   0xfffff

Definition at line 274 of file strtod.cpp.

Referenced by mux_dtoa().

#define IEEE_8087

Definition at line 147 of file strtod.cpp.

#define IEEE_Arith

Definition at line 169 of file strtod.cpp.

Referenced by mux_strtod().

#define Int_max   14

Definition at line 285 of file strtod.cpp.

Referenced by mux_dtoa().

#define Kmax   15

Definition at line 399 of file strtod.cpp.

#define Llong   INT64

Definition at line 393 of file strtod.cpp.

#define Log2P   1

Definition at line 281 of file strtod.cpp.

Referenced by mux_dtoa(), and mux_strtod().

#define Long   INT32

Definition at line 152 of file strtod.cpp.

Referenced by mux_dtoa(), mux_strtod(), s2b(), and ulp().

#define LSB   1

Definition at line 279 of file strtod.cpp.

Referenced by mux_strtod().

#define n_bigtens   5

Definition at line 1336 of file strtod.cpp.

Referenced by mux_dtoa(), and mux_strtod().

#define P   53

Definition at line 267 of file strtod.cpp.

Referenced by d2b(), mux_dtoa(), mux_strtod(), and ulp().

#define PRIVATE_mem   ((PRIVATE_MEM+sizeof(double)-1)/sizeof(double))

Definition at line 159 of file strtod.cpp.

Referenced by Balloc().

#define PRIVATE_MEM   2304

Definition at line 157 of file strtod.cpp.

#define Quick_max   14

Definition at line 284 of file strtod.cpp.

Referenced by mux_dtoa().

#define rounded_product ( a,
 )     a *= b

Definition at line 379 of file strtod.cpp.

Referenced by mux_strtod().

#define rounded_quotient ( a,
 )     a /= b

Definition at line 380 of file strtod.cpp.

Referenced by mux_strtod().

#define Rounding   Flt_Rounds

Definition at line 306 of file strtod.cpp.

Referenced by mux_dtoa(), and mux_strtod().

#define Scale_Bit   0x10

Definition at line 1335 of file strtod.cpp.

Referenced by mux_strtod().

#define Sign_bit   0x80000000

Definition at line 280 of file strtod.cpp.

Referenced by mux_dtoa().

#define Storeinc ( a,
b,
 ) 

Value:

(((unsigned short *)a)[1] = (unsigned short)b, \
((unsigned short *)a)[0] = (unsigned short)c, a++)

Definition at line 248 of file strtod.cpp.

Referenced by diff(), mult(), and quorem().

#define Ten_pmax   22

Definition at line 275 of file strtod.cpp.

Referenced by mux_dtoa(), and mux_strtod().

#define Tiny0   0

Definition at line 282 of file strtod.cpp.

Referenced by mux_strtod().

#define Tiny1   1

Definition at line 283 of file strtod.cpp.

Referenced by mux_strtod().

#define ULLong   UINT64

Definition at line 396 of file strtod.cpp.

Referenced by diff(), mult(), multadd(), and quorem().

#define word0 (  )     ((U*)&x)->L[1]

Definition at line 234 of file strtod.cpp.

Referenced by b2d(), d2b(), mux_dtoa(), mux_strtod(), ratio(), and ulp().

#define word1 (  )     ((U*)&x)->L[0]

Definition at line 235 of file strtod.cpp.

Referenced by b2d(), d2b(), mux_dtoa(), mux_strtod(), and ulp().


Typedef Documentation

typedef struct Bigint Bigint

Definition at line 408 of file strtod.cpp.

typedef UINT32 ULong

Definition at line 153 of file strtod.cpp.


Function Documentation

static double b2d ( Bigint a,
int *  e 
) [static]

Definition at line 1056 of file strtod.cpp.

References d0, d1, dval, Ebits, Exp_1, hi0bits(), Bigint::k, Bigint::wds, word0, word1, and Bigint::x.

Referenced by ratio().

01057 {
01058     ULong *xa, *xa0, w, y, z;
01059     int k;
01060     double d;
01061 #ifdef VAX
01062     ULong d0, d1;
01063 #else
01064 #define d0 word0(d)
01065 #define d1 word1(d)
01066 #endif
01067 
01068     xa0 = a->x;
01069     xa = xa0 + a->wds;
01070     y = *--xa;
01071     k = hi0bits(y);
01072     *e = 32 - k;
01073 #ifdef Pack_32
01074     if (k < Ebits)
01075     {
01076         d0 = Exp_1 | y >> (Ebits - k);
01077         w = xa > xa0 ? *--xa : 0;
01078         d1 = y << ((32-Ebits) + k) | w >> (Ebits - k);
01079         goto ret_d;
01080     }
01081     z = xa > xa0 ? *--xa : 0;
01082     if (k -= Ebits)
01083     {
01084         d0 = Exp_1 | y << k | z >> (32 - k);
01085         y = xa > xa0 ? *--xa : 0;
01086         d1 = z << k | y >> (32 - k);
01087     }
01088     else
01089     {
01090         d0 = Exp_1 | y;
01091         d1 = z;
01092     }
01093 #else
01094     if (k < Ebits + 16)
01095     {
01096         z = xa > xa0 ? *--xa : 0;
01097         d0 = Exp_1 | y << k - Ebits | z >> Ebits + 16 - k;
01098         w = xa > xa0 ? *--xa : 0;
01099         y = xa > xa0 ? *--xa : 0;
01100         d1 = z << k + 16 - Ebits | w << k - Ebits | y >> 16 + Ebits - k;
01101         goto ret_d;
01102     }
01103     z = xa > xa0 ? *--xa : 0;
01104     w = xa > xa0 ? *--xa : 0;
01105     k -= Ebits + 16;
01106     d0 = Exp_1 | y << k + 16 | z << k | w >> 16 - k;
01107     y = xa > xa0 ? *--xa : 0;
01108     d1 = w << k + 16 | y << k;
01109 #endif
01110 ret_d:
01111 #ifdef VAX
01112     word0(d) = d0 >> 16 | d0 << 16;
01113     word1(d) = d1 >> 16 | d1 << 16;
01114 #else
01115 #undef d0
01116 #undef d1
01117 #endif
01118     return dval(d);
01119 }

static Bigint* Balloc ( int  k  )  [static]

Definition at line 412 of file strtod.cpp.

References freelist, ISOUTOFMEMORY, Bigint::k, Bigint::maxwds, MEMALLOC, Bigint::next, pmem_next, PRIVATE_mem, private_mem, Bigint::sign, Bigint::wds, and Bigint::x.

Referenced by d2b(), diff(), i2b(), lshift(), mult(), multadd(), mux_dtoa(), mux_strtod(), rv_alloc(), and s2b().

00413 {
00414     int x;
00415     Bigint *rv;
00416 #ifndef Omit_Private_Memory
00417     unsigned int len;
00418 #endif
00419 
00420     if ((rv = freelist[k]))
00421     {
00422         freelist[k] = rv->next;
00423     }
00424     else
00425     {
00426         x = 1 << k;
00427 #ifdef Omit_Private_Memory
00428         rv = (Bigint *)MEMALLOC(sizeof(Bigint) + (x-1)*sizeof(ULong));
00429         ISOUTOFMEMORY(rv);
00430 #else
00431         len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1)
00432             /sizeof(double);
00433         if (pmem_next - private_mem + len <= PRIVATE_mem)
00434         {
00435             rv = (Bigint*)pmem_next;
00436             pmem_next += len;
00437         }
00438         else
00439         {
00440             rv = (Bigint*)MEMALLOC(len*sizeof(double));
00441             ISOUTOFMEMORY(rv);
00442         }
00443 #endif
00444         rv->k = k;
00445         rv->maxwds = x;
00446     }
00447     rv->sign = rv->wds = 0;
00448     return rv;
00449 }

static void Bfree ( Bigint v  )  [static]

Definition at line 451 of file strtod.cpp.

References freelist, Bigint::k, and Bigint::next.

Referenced by freedtoa(), lshift(), multadd(), mux_dtoa(), mux_strtod(), and pow5mult().

00452 {
00453     if (v)
00454     {
00455         v->next = freelist[v->k];
00456         freelist[v->k] = v;
00457     }
00458 }

static int cmp ( Bigint a,
Bigint b 
) [static]

Definition at line 890 of file strtod.cpp.

References Bigint::wds, and Bigint::x.

Referenced by diff(), mux_dtoa(), mux_strtod(), and quorem().

00891 {
00892     ULong *xa, *xa0, *xb, *xb0;
00893     int i, j;
00894 
00895     i = a->wds;
00896     j = b->wds;
00897     if (i -= j)
00898     {
00899         return i;
00900     }
00901     xa0 = a->x;
00902     xa = xa0 + j;
00903     xb0 = b->x;
00904     xb = xb0 + j;
00905     for (;;)
00906     {
00907         if (*--xa != *--xb)
00908         {
00909             return *xa < *xb ? -1 : 1;
00910         }
00911         if (xa <= xa0)
00912         {
00913             break;
00914         }
00915     }
00916     return 0;
00917 }

static Bigint* d2b ( double  d,
int *  e,
int *  bits 
) [static]

Definition at line 1121 of file strtod.cpp.

References Balloc(), Bias, d0, d1, Exp_msk1, Exp_msk11, Exp_shift, Frac_mask, hi0bits(), Bigint::k, lo0bits(), P, Bigint::wds, word0, word1, and Bigint::x.

Referenced by mux_dtoa(), and mux_strtod().

01122 {
01123     Bigint *b;
01124     int de, k;
01125     ULong *x, y, z;
01126 #ifndef Sudden_Underflow
01127     int i;
01128 #endif
01129 #ifdef VAX
01130     ULong d0, d1;
01131     d0 = word0(d) >> 16 | word0(d) << 16;
01132     d1 = word1(d) >> 16 | word1(d) << 16;
01133 #else
01134 #define d0 word0(d)
01135 #define d1 word1(d)
01136 #endif
01137 
01138 #ifdef Pack_32
01139     b = Balloc(1);
01140 #else
01141     b = Balloc(2);
01142 #endif
01143     x = b->x;
01144 
01145     z = d0 & Frac_mask;
01146     d0 &= 0x7fffffff;   /* clear sign bit, which we ignore */
01147 #ifdef Sudden_Underflow
01148     de = (int)(d0 >> Exp_shift);
01149 #ifndef IBM
01150     z |= Exp_msk11;
01151 #endif
01152 #else
01153     if ((de = (int)(d0 >> Exp_shift)))
01154     {
01155         z |= Exp_msk1;
01156     }
01157 #endif
01158 #ifdef Pack_32
01159     if ((y = d1))
01160     {
01161         if ((k = lo0bits(&y)))
01162         {
01163             x[0] = y | z << (32 - k);
01164             z >>= k;
01165         }
01166         else
01167         {
01168             x[0] = y;
01169         }
01170 #ifndef Sudden_Underflow
01171         i =
01172 #endif
01173             b->wds = (x[1] = z) ? 2 : 1;
01174     }
01175     else
01176     {
01177         k = lo0bits(&z);
01178         x[0] = z;
01179 #ifndef Sudden_Underflow
01180         i =
01181 #endif
01182             b->wds = 1;
01183         k += 32;
01184     }
01185 #else
01186     if (y = d1)
01187     {
01188         if (k = lo0bits(&y))
01189         {
01190             if (k >= 16)
01191             {
01192                 x[0] = y | z << 32 - k & 0xffff;
01193                 x[1] = z >> k - 16 & 0xffff;
01194                 x[2] = z >> k;
01195                 i = 2;
01196             }
01197             else
01198             {
01199                 x[0] = y & 0xffff;
01200                 x[1] = y >> 16 | z << 16 - k & 0xffff;
01201                 x[2] = z >> k & 0xffff;
01202                 x[3] = z >> k+16;
01203                 i = 3;
01204             }
01205         }
01206         else
01207         {
01208             x[0] = y & 0xffff;
01209             x[1] = y >> 16;
01210             x[2] = z & 0xffff;
01211             x[3] = z >> 16;
01212             i = 3;
01213         }
01214     }
01215     else
01216     {
01217         k = lo0bits(&z);
01218         if (k >= 16)
01219         {
01220             x[0] = z;
01221             i = 0;
01222         }
01223         else
01224         {
01225             x[0] = z & 0xffff;
01226             x[1] = z >> 16;
01227             i = 1;
01228         }
01229         k += 32;
01230     }
01231     while (!x[i])
01232     {
01233         --i;
01234     }
01235     b->wds = i + 1;
01236 #endif
01237 #ifndef Sudden_Underflow
01238     if (de)
01239     {
01240 #endif
01241 #ifdef IBM
01242         *e = (de - Bias - (P-1) << 2) + k;
01243         *bits = 4*P + 8 - k - hi0bits(word0(d) & Frac_mask);
01244 #else
01245         *e = de - Bias - (P-1) + k;
01246         *bits = P - k;
01247 #endif
01248 #ifndef Sudden_Underflow
01249     }
01250     else
01251     {
01252         *e = de - Bias - (P-1) + 1 + k;
01253 #ifdef Pack_32
01254         *bits = 32*i - hi0bits(x[i-1]);
01255 #else
01256         *bits = (i+2)*16 - hi0bits(x[i]);
01257 #endif
01258     }
01259 #endif
01260     return b;
01261 }

static Bigint* diff ( Bigint a,
Bigint b 
) [static]

Definition at line 919 of file strtod.cpp.

References Balloc(), cmp(), Bigint::k, Bigint::sign, Storeinc, ULLong, Bigint::wds, and Bigint::x.

Referenced by FUNCTION(), mux_dtoa(), and mux_strtod().

00920 {
00921     Bigint *c;
00922     int i, wa, wb;
00923     ULong *xa, *xae, *xb, *xbe, *xc;
00924 #ifdef ULLong
00925     ULLong borrow, y;
00926 #else
00927     ULong borrow, y;
00928 #ifdef Pack_32
00929     ULong z;
00930 #endif
00931 #endif
00932 
00933     i = cmp(a,b);
00934     if (!i)
00935     {
00936         c = Balloc(0);
00937         c->wds = 1;
00938         c->x[0] = 0;
00939         return c;
00940     }
00941     if (i < 0)
00942     {
00943         c = a;
00944         a = b;
00945         b = c;
00946         i = 1;
00947     }
00948     else
00949     {
00950         i = 0;
00951     }
00952     c = Balloc(a->k);
00953     c->sign = i;
00954     wa = a->wds;
00955     xa = a->x;
00956     xae = xa + wa;
00957     wb = b->wds;
00958     xb = b->x;
00959     xbe = xb + wb;
00960     xc = c->x;
00961     borrow = 0;
00962 #ifdef ULLong
00963     do
00964     {
00965         y = (ULLong)*xa++ - *xb++ - borrow;
00966         borrow = y >> 32 & (ULong)1;
00967         *xc++ = (unsigned int)(y & 0xFFFFFFFF);
00968     } while (xb < xbe);
00969     while (xa < xae)
00970     {
00971         y = *xa++ - borrow;
00972         borrow = y >> 32 & (ULong)1;
00973         *xc++ = (unsigned int)(y & 0xFFFFFFFF);
00974     }
00975 #else
00976 #ifdef Pack_32
00977     do
00978     {
00979         y = (*xa & 0xffff) - (*xb & 0xffff) - borrow;
00980         borrow = (y & 0x10000) >> 16;
00981         z = (*xa++ >> 16) - (*xb++ >> 16) - borrow;
00982         borrow = (z & 0x10000) >> 16;
00983         Storeinc(xc, z, y);
00984     } while (xb < xbe);
00985     while (xa < xae)
00986     {
00987         y = (*xa & 0xffff) - borrow;
00988         borrow = (y & 0x10000) >> 16;
00989         z = (*xa++ >> 16) - borrow;
00990         borrow = (z & 0x10000) >> 16;
00991         Storeinc(xc, z, y);
00992     }
00993 #else
00994     do
00995     {
00996         y = *xa++ - *xb++ - borrow;
00997         borrow = (y & 0x10000) >> 16;
00998         *xc++ = y & 0xffff;
00999     } while (xb < xbe);
01000     while (xa < xae)
01001     {
01002         y = *xa++ - borrow;
01003         borrow = (y & 0x10000) >> 16;
01004         *xc++ = y & 0xffff;
01005     }
01006 #endif
01007 #endif
01008     while (!*--xc)
01009     {
01010         wa--;
01011     }
01012     c->wds = wa;
01013     return c;
01014 }

void FLOAT_Initialize ( void   ) 

Definition at line 3603 of file strtod.cpp.

References mux_FPInit(), and mux_FPSet().

Referenced by main().

03604 {
03605     mux_FPInit();
03606     mux_FPSet();
03607 }

static void freedtoa ( char *  s  )  [static]

Definition at line 2581 of file strtod.cpp.

References Bfree(), dtoa_result, Bigint::k, and Bigint::maxwds.

Referenced by mux_dtoa().

02582 {
02583     Bigint *b = (Bigint *)((int *)s - 1);
02584     b->maxwds = 1 << (b->k = *(int*)b);
02585     Bfree(b);
02586     if (s == dtoa_result)
02587     {
02588         dtoa_result = 0;
02589     }
02590 }

static int hi0bits ( register ULong  x  )  [static]

Definition at line 560 of file strtod.cpp.

References Bigint::k.

Referenced by b2d(), d2b(), and mux_dtoa().

00561 {
00562     register int k = 0;
00563 
00564     if (!(x & 0xffff0000))
00565     {
00566         k = 16;
00567         x <<= 16;
00568     }
00569     if (!(x & 0xff000000))
00570     {
00571         k += 8;
00572         x <<= 8;
00573     }
00574     if (!(x & 0xf0000000))
00575     {
00576         k += 4;
00577         x <<= 4;
00578     }
00579     if (!(x & 0xc0000000))
00580     {
00581         k += 2;
00582         x <<= 2;
00583     }
00584     if (!(x & 0x80000000))
00585     {
00586         k++;
00587         if (!(x & 0x40000000))
00588         {
00589             return 32;
00590         }
00591     }
00592     return k;
00593 }

static Bigint* i2b ( int  i  )  [static]

Definition at line 648 of file strtod.cpp.

References Balloc(), Bigint::wds, and Bigint::x.

Referenced by mux_dtoa(), mux_strtod(), and pow5mult().

00649 {
00650     Bigint *b;
00651 
00652     b = Balloc(1);
00653     b->x[0] = i;
00654     b->wds = 1;
00655     return b;
00656 }

static int lo0bits ( ULong y  )  [static]

Definition at line 595 of file strtod.cpp.

References Bigint::k, and Bigint::x.

Referenced by d2b().

00596 {
00597     register int k;
00598     register ULong x = *y;
00599 
00600     if (x & 7)
00601     {
00602         if (x & 1)
00603         {
00604             return 0;
00605         }
00606         if (x & 2)
00607         {
00608             *y = x >> 1;
00609             return 1;
00610         }
00611         *y = x >> 2;
00612         return 2;
00613     }
00614     k = 0;
00615     if (!(x & 0xffff))
00616     {
00617         k = 16;
00618         x >>= 16;
00619     }
00620     if (!(x & 0xff))
00621     {
00622         k += 8;
00623         x >>= 8;
00624     }
00625     if (!(x & 0xf))
00626     {
00627         k += 4;
00628         x >>= 4;
00629     }
00630     if (!(x & 0x3))
00631     {
00632         k += 2;
00633         x >>= 2;
00634     }
00635     if (!(x & 1))
00636     {
00637         k++;
00638         x >>= 1;
00639         if (!(x & 1))
00640         {
00641             return 32;
00642         }
00643     }
00644     *y = x;
00645     return k;
00646 }

static Bigint* lshift ( Bigint b,
int  k 
) [static]

Definition at line 822 of file strtod.cpp.

References Balloc(), Bfree(), Bigint::k, Bigint::maxwds, Bigint::wds, and Bigint::x.

Referenced by mux_dtoa(), and mux_strtod().

00823 {
00824     int i, k1, n, n1;
00825     Bigint *b1;
00826     ULong *x, *x1, *xe, z;
00827 
00828 #ifdef Pack_32
00829     n = k >> 5;
00830 #else
00831     n = k >> 4;
00832 #endif
00833     k1 = b->k;
00834     n1 = n + b->wds + 1;
00835     for (i = b->maxwds; n1 > i; i <<= 1)
00836     {
00837         k1++;
00838     }
00839     b1 = Balloc(k1);
00840     x1 = b1->x;
00841     for (i = 0; i < n; i++)
00842     {
00843         *x1++ = 0;
00844     }
00845     x = b->x;
00846     xe = x + b->wds;
00847 #ifdef Pack_32
00848     if (k &= 0x1f)
00849     {
00850         k1 = 32 - k;
00851         z = 0;
00852         do
00853         {
00854             *x1++ = *x << k | z;
00855             z = *x++ >> k1;
00856         } while (x < xe);
00857         if ((*x1 = z))
00858         {
00859             ++n1;
00860         }
00861     }
00862 #else
00863     if (k &= 0xf)
00864     {
00865         k1 = 16 - k;
00866         z = 0;
00867         do
00868         {
00869             *x1++ = *x << k  & 0xffff | z;
00870             z = *x++ >> k1;
00871         } while (x < xe);
00872         if (*x1 = z)
00873         {
00874             ++n1;
00875         }
00876     }
00877 #endif
00878     else
00879     {
00880         do
00881         {
00882             *x1++ = *x++;
00883         } while (x < xe);
00884     }
00885     b1->wds = n1 - 1;
00886     Bfree(b);
00887     return b1;
00888 }

static Bigint* mult ( Bigint a,
Bigint b 
) [static]

Definition at line 658 of file strtod.cpp.

References Balloc(), Bigint::k, Bigint::maxwds, Storeinc, ULLong<