/home/coin/svn-release/OS-2.10.0/OS/src/OSUtils/OSdtoa.cpp File Reference

#include "OSConfig.h"
#include "OSdtoa.h"
#include "OSParameters.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "errno.h"
#include "float.h"
#include "math.h"
Include dependency graph for OSdtoa.cpp:

Go to the source code of this file.

Classes

union  U
struct  BCinfo
struct  Bigint

Defines

#define IEEE_8087
 the following is OS code put bigendian check here
#define INFNAN_CHECK
#define NO_LONG_LONG
#define Just_16
#define Long   int
#define Intcast   (int)(long)
#define Bug(x)   {fprintf(stderr, "%s\n", x); exit(1);}
#define MALLOC   malloc
#define PRIVATE_MEM   2304
#define PRIVATE_mem   ((PRIVATE_MEM+sizeof(double)-1)/sizeof(double))
#define IEEE_Arith
#define INFNAN_CHECK
#define CONST   const
#define word0(x)   (x)->L[1]
#define word1(x)   (x)->L[0]
#define dval(x)   (x)->d
#define STRTOD_DIGLIM   40
#define strtod_diglim   STRTOD_DIGLIM
#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 Nbits   53
#define Bias   1023
#define Emax   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 ACQUIRE_DTOA_LOCK(n)
#define FREE_DTOA_LOCK(n)
#define Kmax   7
#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
#define Need_Hexdig
#define NAN_WORD0   0x7ff80000
#define NAN_WORD1   0
#define ULbits   16
#define kshift   4
#define kmask   15

Typedefs

typedef unsigned Long ULong
 end of OS code, below is David Gay, except as noted above
typedef struct BCinfo BCinfo
typedef struct Bigint Bigint

Enumerations

enum  { Round_zero = 0, Round_near = 1, Round_up = 2, Round_down = 3 }

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, int dplen)
static int hi0bits (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)
static double ulp (U *x)
static double b2d (Bigint *a, int *e)
static Bigintd2b (U *d, int *e, int *bits)
static double ratio (Bigint *a, Bigint *b)
static int match (const char **sp, const char *t)
static void hexnan (U *rvp, const char **sp)
static Bigintincrement (Bigint *b)
static void rshift (Bigint *b, int k)
static ULong any_on (Bigint *b, int k)
void os_gethex (CONST char **sp, U *rvp, int rounding, int sign)
static int dshift (Bigint *b, int p2)
static int quorem (Bigint *b, Bigint *S)
static double sulp (U *x, BCinfo *bc)
static void bigcomp (U *rv, const char *s0, BCinfo *bc)
double os_strtod (const char *s00, char **se)
static char * rv_alloc (int i)
static char * nrv_alloc (const char *s, char **rve, int n)
void os_freedtoa (char *s)
char * os_dtoa (double dd, int mode, int ndigits, int *decpt, int *sign, char **rve)

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 unsigned char hexdig [256]
static char * dtoa_result

Define Documentation

#define IEEE_8087

the following is OS code put bigendian check here

Definition at line 28 of file OSdtoa.cpp.

#define INFNAN_CHECK

Definition at line 292 of file OSdtoa.cpp.

#define NO_LONG_LONG

Definition at line 33 of file OSdtoa.cpp.

#define Just_16

Definition at line 34 of file OSdtoa.cpp.

#define Long   int

Definition at line 37 of file OSdtoa.cpp.

#define Intcast   (int)(long)

Definition at line 38 of file OSdtoa.cpp.

#define Bug ( x   )     {fprintf(stderr, "%s\n", x); exit(1);}

Definition at line 246 of file OSdtoa.cpp.

#define MALLOC   malloc

Definition at line 269 of file OSdtoa.cpp.

#define PRIVATE_MEM   2304

Definition at line 274 of file OSdtoa.cpp.

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

Definition at line 276 of file OSdtoa.cpp.

#define IEEE_Arith

Definition at line 286 of file OSdtoa.cpp.

#define INFNAN_CHECK

Definition at line 292 of file OSdtoa.cpp.

#define CONST   const

Definition at line 346 of file OSdtoa.cpp.

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

Definition at line 357 of file OSdtoa.cpp.

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

Definition at line 358 of file OSdtoa.cpp.

#define dval ( x   )     (x)->d

Definition at line 363 of file OSdtoa.cpp.

#define STRTOD_DIGLIM   40

Definition at line 366 of file OSdtoa.cpp.

#define strtod_diglim   STRTOD_DIGLIM

Definition at line 372 of file OSdtoa.cpp.

#define Storeinc ( a,
b,
c   ) 
Value:
(((unsigned short *)a)[1] = (unsigned short)b, \
((unsigned short *)a)[0] = (unsigned short)c, a++)

Definition at line 380 of file OSdtoa.cpp.

#define Exp_shift   20

Definition at line 394 of file OSdtoa.cpp.

#define Exp_shift1   20

Definition at line 395 of file OSdtoa.cpp.

#define Exp_msk1   0x100000

Definition at line 396 of file OSdtoa.cpp.

#define Exp_msk11   0x100000

Definition at line 397 of file OSdtoa.cpp.

#define Exp_mask   0x7ff00000

Definition at line 398 of file OSdtoa.cpp.

#define P   53

Definition at line 399 of file OSdtoa.cpp.

#define Nbits   53

Definition at line 400 of file OSdtoa.cpp.

#define Bias   1023

Definition at line 401 of file OSdtoa.cpp.

#define Emax   1023

Definition at line 402 of file OSdtoa.cpp.

#define Emin   (-1022)

Definition at line 403 of file OSdtoa.cpp.

#define Exp_1   0x3ff00000

Definition at line 404 of file OSdtoa.cpp.

#define Exp_11   0x3ff00000

Definition at line 405 of file OSdtoa.cpp.

#define Ebits   11

Definition at line 406 of file OSdtoa.cpp.

#define Frac_mask   0xfffff

Definition at line 407 of file OSdtoa.cpp.

#define Frac_mask1   0xfffff

Definition at line 408 of file OSdtoa.cpp.

#define Ten_pmax   22

Definition at line 409 of file OSdtoa.cpp.

#define Bletch   0x10

Definition at line 410 of file OSdtoa.cpp.

#define Bndry_mask   0xfffff

Definition at line 411 of file OSdtoa.cpp.

#define Bndry_mask1   0xfffff

Definition at line 412 of file OSdtoa.cpp.

#define LSB   1

Definition at line 413 of file OSdtoa.cpp.

#define Sign_bit   0x80000000

Definition at line 414 of file OSdtoa.cpp.

#define Log2P   1

Definition at line 415 of file OSdtoa.cpp.

#define Tiny0   0

Definition at line 416 of file OSdtoa.cpp.

#define Tiny1   1

Definition at line 417 of file OSdtoa.cpp.

#define Quick_max   14

Definition at line 418 of file OSdtoa.cpp.

#define Int_max   14

Definition at line 419 of file OSdtoa.cpp.

#define Avoid_Underflow

Definition at line 421 of file OSdtoa.cpp.

#define Flt_Rounds   1

Definition at line 431 of file OSdtoa.cpp.

#define Rounding   Flt_Rounds

Definition at line 439 of file OSdtoa.cpp.

#define rounded_product ( a,
 )     a *= b

Definition at line 527 of file OSdtoa.cpp.

#define rounded_quotient ( a,
 )     a /= b

Definition at line 528 of file OSdtoa.cpp.

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

Definition at line 531 of file OSdtoa.cpp.

#define Big1   0xffffffff

Definition at line 532 of file OSdtoa.cpp.

#define FFFFFFFF   0xffffffffUL

Definition at line 545 of file OSdtoa.cpp.

#define ACQUIRE_DTOA_LOCK ( n   ) 

Definition at line 568 of file OSdtoa.cpp.

#define FREE_DTOA_LOCK ( n   ) 

Definition at line 569 of file OSdtoa.cpp.

#define Kmax   7

Definition at line 572 of file OSdtoa.cpp.

#define Bcopy ( x,
 ) 
Value:
memcpy((char *)&x->sign, (char *)&y->sign, \
y->wds*sizeof(Long) + 2*sizeof(int))

Definition at line 656 of file OSdtoa.cpp.

#define d0   word0(&d)
#define d1   word1(&d)
#define d0   word0(d)
#define d1   word1(d)
#define Scale_Bit   0x10

Definition at line 1519 of file OSdtoa.cpp.

#define n_bigtens   5

Definition at line 1520 of file OSdtoa.cpp.

#define Need_Hexdig

Definition at line 1536 of file OSdtoa.cpp.

#define NAN_WORD0   0x7ff80000

Definition at line 1592 of file OSdtoa.cpp.

#define NAN_WORD1   0

Definition at line 1596 of file OSdtoa.cpp.

#define ULbits   16

Definition at line 1694 of file OSdtoa.cpp.

#define kshift   4

Definition at line 1695 of file OSdtoa.cpp.

#define kmask   15

Definition at line 1696 of file OSdtoa.cpp.


Typedef Documentation

typedef unsigned Long ULong

end of OS code, below is David Gay, except as noted above

Definition at line 239 of file OSdtoa.cpp.

typedef struct BCinfo BCinfo

Definition at line 538 of file OSdtoa.cpp.

typedef struct Bigint Bigint

Definition at line 587 of file OSdtoa.cpp.


Enumeration Type Documentation

anonymous enum
Enumerator:
Round_zero 
Round_near 
Round_up 
Round_down 

Definition at line 1798 of file OSdtoa.cpp.


Function Documentation

static Bigint* Balloc ( int  k  )  [static]

Definition at line 596 of file OSdtoa.cpp.

static void Bfree ( Bigint v  )  [static]

Definition at line 637 of file OSdtoa.cpp.

static Bigint* multadd ( Bigint b,
int  m,
int  a 
) [static]

Definition at line 664 of file OSdtoa.cpp.

static Bigint* s2b ( const char *  s,
int  nd0,
int  nd,
ULong  y9,
int  dplen 
) [static]

Definition at line 721 of file OSdtoa.cpp.

static int hi0bits ( ULong  x  )  [static]

Definition at line 759 of file OSdtoa.cpp.

static int lo0bits ( ULong y  )  [static]

Definition at line 793 of file OSdtoa.cpp.

static Bigint* i2b ( int  i  )  [static]

Definition at line 841 of file OSdtoa.cpp.

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

Definition at line 857 of file OSdtoa.cpp.

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

Definition at line 969 of file OSdtoa.cpp.

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

Definition at line 1026 of file OSdtoa.cpp.

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

Definition at line 1086 of file OSdtoa.cpp.

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

Definition at line 1120 of file OSdtoa.cpp.

static double ulp ( U x  )  [static]

Definition at line 1214 of file OSdtoa.cpp.

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

Definition at line 1256 of file OSdtoa.cpp.

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

Definition at line 1326 of file OSdtoa.cpp.

static double ratio ( Bigint a,
Bigint b 
) [static]

Definition at line 1460 of file OSdtoa.cpp.

static int match ( const char **  sp,
const char *  t 
) [static]

Definition at line 1604 of file OSdtoa.cpp.

static void hexnan ( U rvp,
const char **  sp 
) [static]

Definition at line 1626 of file OSdtoa.cpp.

static Bigint* increment ( Bigint b  )  [static]

Definition at line 1704 of file OSdtoa.cpp.

static void rshift ( Bigint b,
int  k 
) [static]

Definition at line 1739 of file OSdtoa.cpp.

static ULong any_on ( Bigint b,
int  k 
) [static]

Definition at line 1772 of file OSdtoa.cpp.

void os_gethex ( CONST char **  sp,
U rvp,
int  rounding,
int  sign 
)

Definition at line 1810 of file OSdtoa.cpp.

static int dshift ( Bigint b,
int  p2 
) [static]

NO_HEX_FP}

Definition at line 2171 of file OSdtoa.cpp.

static int quorem ( Bigint b,
Bigint S 
) [static]

Definition at line 2185 of file OSdtoa.cpp.

static double sulp ( U x,
BCinfo bc 
) [static]

Definition at line 2310 of file OSdtoa.cpp.

static void bigcomp ( U rv,
const char *  s0,
BCinfo bc 
) [static]

Definition at line 2333 of file OSdtoa.cpp.

double os_strtod ( const char *  s00,
char **  se 
)

Definition at line 2541 of file OSdtoa.cpp.

static char* rv_alloc ( int  i  )  [static]

Definition at line 3617 of file OSdtoa.cpp.

static char* nrv_alloc ( const char *  s,
char **  rve,
int  n 
) [static]

Definition at line 3640 of file OSdtoa.cpp.

void os_freedtoa ( char *  s  ) 

Definition at line 3662 of file OSdtoa.cpp.

char* os_dtoa ( double  dd,
int  mode,
int  ndigits,
int *  decpt,
int *  sign,
char **  rve 
)

Definition at line 3714 of file OSdtoa.cpp.


Variable Documentation

double private_mem[PRIVATE_mem] [static]

Definition at line 277 of file OSdtoa.cpp.

double * pmem_next = private_mem [static]

Definition at line 277 of file OSdtoa.cpp.

Bigint* freelist[Kmax+1] [static]

Definition at line 589 of file OSdtoa.cpp.

Bigint* p5s [static]

Definition at line 962 of file OSdtoa.cpp.

CONST double tens[] [static]
Initial value:
 {
                1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,
                1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
                1e20, 1e21, 1e22



                }

Definition at line 1497 of file OSdtoa.cpp.

CONST double bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 } [static]

Definition at line 1508 of file OSdtoa.cpp.

CONST double tinytens[] [static]
Initial value:
 { 1e-16, 1e-32, 1e-64, 1e-128,

                9007199254740992.*9007199254740992.e-256
                



                }

Definition at line 1509 of file OSdtoa.cpp.

unsigned char hexdig[256] [static]
Initial value:
 {
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
        16,17,18,19,20,21,22,23,24,25,0,0,0,0,0,0,
        0,26,27,28,29,30,31,0,0,0,0,0,0,0,0,0,
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
        0,26,27,28,29,30,31,0,0,0,0,0,0,0,0,0,
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
        }

Definition at line 1568 of file OSdtoa.cpp.

char* dtoa_result [static]

Definition at line 3610 of file OSdtoa.cpp.


Generated on 5 Jul 2015 by  doxygen 1.6.1