- Main Page
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# /home/coin/SVN-release/OS-2.3.5/OS/src/OSUtils/OSdtoa.cpp File Reference

`#include "OSConfig.h"`
`#include "OSdtoa.h"`
`#include "OSParameters.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 | 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 | 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) ((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 | ACQUIRE_DTOA_LOCK(n)
#define | FREE_DTOA_LOCK(n)
#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
#define | NAN_WORD0 0x7ff80000
#define | NAN_WORD1 0
## Typedefs
typedef unsigned Long | ULong
| end of OS code, below is David Gay except we changed the names of dtoa to os_dtoa strtod to os-strtod and freedtoa to os_freedtoa
typedef Bigint | Bigint
## Functions
static Bigint * | Balloc (int k)
static void | Bfree (Bigint *v)
static Bigint * | multadd (Bigint *b, int m, int a)
static Bigint * | s2b (CONST char *s, int nd0, int nd, ULong y9)
static int | hi0bits (register ULong x)
static int | lo0bits (ULong *y)
static Bigint * | i2b (int i)
static Bigint * | mult (Bigint *a, Bigint *b)
static Bigint * | pow5mult (Bigint *b, int k)
static Bigint * | lshift (Bigint *b, int k)
static int | cmp (Bigint *a, Bigint *b)
static Bigint * | diff (Bigint *a, Bigint *b)
static double | ulp (double x)
static double | b2d (Bigint *a, int *e)
static Bigint * | d2b (double d, int *e, int *bits)
static double | ratio (Bigint *a, Bigint *b)
static int | match (CONST char **sp, CONST char *t)
static void | hexnan (double *rvp, CONST char **sp)
double | os_strtod (CONST char *s00, char **se)
static int | quorem (Bigint *b, Bigint *S)
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 d, int mode, int ndigits, int *decpt, int *sign, char **rve)
## Variables
static double | private_mem [PRIVATE_mem]
static double * | pmem_next = private_mem
static Bigint * | freelist [Kmax+1]
static Bigint * | p5s
static CONST double | tens []
static CONST double | bigtens [] = { 1e16, 1e32, 1e64, 1e128, 1e256 }
static CONST double | tinytens []
static char * | dtoa_result

## Define Documentation

#define IEEE_8087

the following is OS code put bigendian check here

Definition at line 184 of file OSdtoa.cpp.

#define INFNAN_CHECK

Definition at line 268 of file OSdtoa.cpp.

Referenced by os_strtod().

#define NO_LONG_LONG

Definition at line 191 of file OSdtoa.cpp.

#define Just_16

Definition at line 192 of file OSdtoa.cpp.

#define Long int

Definition at line 202 of file OSdtoa.cpp.

Referenced by os_dtoa(), os_strtod(), s2b(), and ulp().

#define Intcast (int)(long)

Definition at line 203 of file OSdtoa.cpp.

Referenced by OSnl2osil::walkTree().

#define MALLOC malloc

Definition at line 245 of file OSdtoa.cpp.

Referenced by Balloc().

#define PRIVATE_MEM 2304

Definition at line 250 of file OSdtoa.cpp.

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

Definition at line 252 of file OSdtoa.cpp.

Referenced by Balloc().

#define IEEE_Arith

Definition at line 262 of file OSdtoa.cpp.

Referenced by os_strtod().

#define INFNAN_CHECK

Definition at line 268 of file OSdtoa.cpp.

#define CONST const

Definition at line 321 of file OSdtoa.cpp.

Referenced by hexnan(), match(), and os_strtod().

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

Definition at line 342 of file OSdtoa.cpp.

Referenced by b2d(), d2b(), hexnan(), os_dtoa(), os_strtod(), ratio(), and ulp().

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

Definition at line 343 of file OSdtoa.cpp.

Referenced by b2d(), d2b(), hexnan(), os_dtoa(), os_strtod(), and ulp().

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

Definition at line 348 of file OSdtoa.cpp.

Referenced by b2d(), os_dtoa(), os_strtod(), ratio(), and ulp().

#define Storeinc | ( | a,
|  | b,
|  | c |  | ) |

Value:

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

Definition at line 356 of file OSdtoa.cpp.

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

#define Exp_shift 20

Definition at line 370 of file OSdtoa.cpp.

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

#define Exp_shift1 20

Definition at line 371 of file OSdtoa.cpp.

Referenced by os_dtoa().

#define Exp_msk1 0x100000

Definition at line 372 of file OSdtoa.cpp.

Referenced by d2b(), os_dtoa(), os_strtod(), ratio(), and ulp().

#define Exp_msk11 0x100000

Definition at line 373 of file OSdtoa.cpp.

Referenced by d2b().

#define Exp_mask 0x7ff00000

Definition at line 374 of file OSdtoa.cpp.

Referenced by hexnan(), os_dtoa(), os_strtod(), and ulp().

#define P 53

Definition at line 375 of file OSdtoa.cpp.

Referenced by d2b(), os_dtoa(), os_strtod(), and ulp().

#define Bias 1023

Definition at line 376 of file OSdtoa.cpp.

Referenced by d2b(), os_dtoa(), and os_strtod().

#define Emin (-1022)

Definition at line 377 of file OSdtoa.cpp.

Referenced by os_strtod().

#define Exp_1 0x3ff00000

Definition at line 378 of file OSdtoa.cpp.

Referenced by b2d(), and os_strtod().

#define Exp_11 0x3ff00000

Definition at line 379 of file OSdtoa.cpp.

Referenced by os_dtoa().

#define Ebits 11

Definition at line 380 of file OSdtoa.cpp.

Referenced by b2d().

#define Frac_mask 0xfffff

Definition at line 381 of file OSdtoa.cpp.

Referenced by d2b(), os_dtoa(), and os_strtod().

#define Frac_mask1 0xfffff

Definition at line 382 of file OSdtoa.cpp.

Referenced by os_dtoa().

#define Ten_pmax 22

Definition at line 383 of file OSdtoa.cpp.

Referenced by os_dtoa(), and os_strtod().

#define Bletch 0x10

Definition at line 384 of file OSdtoa.cpp.

Referenced by os_dtoa().

#define Bndry_mask 0xfffff

Definition at line 385 of file OSdtoa.cpp.

Referenced by os_dtoa(), and os_strtod().

#define Bndry_mask1 0xfffff

Definition at line 386 of file OSdtoa.cpp.

Referenced by os_strtod().

#define LSB 1

Definition at line 387 of file OSdtoa.cpp.

Referenced by os_strtod().

#define Sign_bit 0x80000000

Definition at line 388 of file OSdtoa.cpp.

Referenced by os_dtoa().

#define Log2P 1

Definition at line 389 of file OSdtoa.cpp.

Referenced by os_dtoa(), and os_strtod().

#define Tiny0 0

Definition at line 390 of file OSdtoa.cpp.

Referenced by os_strtod().

#define Tiny1 1

Definition at line 391 of file OSdtoa.cpp.

Referenced by os_strtod().

#define Quick_max 14

Definition at line 392 of file OSdtoa.cpp.

Referenced by os_dtoa().

#define Int_max 14

Definition at line 393 of file OSdtoa.cpp.

Referenced by os_dtoa().

#define Avoid_Underflow

Definition at line 395 of file OSdtoa.cpp.

Referenced by os_strtod().

#define Flt_Rounds 1

Definition at line 405 of file OSdtoa.cpp.

Referenced by os_dtoa(), and os_strtod().

#define Rounding Flt_Rounds

Definition at line 414 of file OSdtoa.cpp.

Referenced by os_dtoa(), and os_strtod().

#define rounded_product | ( | a,
|  | b |  | ) | a *= b

Definition at line 491 of file OSdtoa.cpp.

Referenced by os_strtod().

#define rounded_quotient | ( | a,
|  | b |  | ) | a /= b

Definition at line 492 of file OSdtoa.cpp.

Referenced by os_strtod().

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

Definition at line 495 of file OSdtoa.cpp.

Referenced by os_strtod().

#define Big1 0xffffffff

Definition at line 496 of file OSdtoa.cpp.

Referenced by os_strtod().

#define FFFFFFFF 0xffffffffUL

Definition at line 505 of file OSdtoa.cpp.

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

#define ACQUIRE_DTOA_LOCK | ( | n |  | ) |

Definition at line 528 of file OSdtoa.cpp.

Referenced by Balloc(), Bfree(), and pow5mult().

#define FREE_DTOA_LOCK | ( | n |  | ) |

Definition at line 529 of file OSdtoa.cpp.

Referenced by Balloc(), Bfree(), and pow5mult().

#define Kmax 15

Definition at line 532 of file OSdtoa.cpp.

#define Bcopy | ( | x,
|  | y |  | ) |

Value:

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

Definition at line 609 of file OSdtoa.cpp.

Referenced by multadd(), os_dtoa(), and os_strtod().

#define d0 word0(d)

Referenced by b2d(), and d2b().

#define d1 word1(d)

Referenced by b2d(), d2b(), and OSRouteSolver::getOptL().

#define d0 word0(d)

#define d1 word1(d)

#define Scale_Bit 0x10

Definition at line 1476 of file OSdtoa.cpp.

Referenced by os_strtod().

#define n_bigtens 5

Definition at line 1477 of file OSdtoa.cpp.

Referenced by os_dtoa(), and os_strtod().

#define NAN_WORD0 0x7ff80000

Definition at line 1493 of file OSdtoa.cpp.

Referenced by os_strtod().

#define NAN_WORD1 0

Definition at line 1497 of file OSdtoa.cpp.

Referenced by os_strtod().

## Typedef Documentation

typedef unsigned Long ULong

end of OS code, below is David Gay except we changed the names of dtoa to os_dtoa strtod to os-strtod and freedtoa to os_freedtoa

Definition at line 223 of file OSdtoa.cpp.

typedef struct Bigint Bigint

Definition at line 547 of file OSdtoa.cpp.

## Function Documentation

static Bigint* Balloc | ( | int | k | ) | `[static]`

Definition at line 556 of file OSdtoa.cpp.

References ACQUIRE_DTOA_LOCK, FREE_DTOA_LOCK, freelist, Bigint::k, MALLOC, Bigint::maxwds, Bigint::next, pmem_next, private_mem, PRIVATE_mem, Bigint::sign, Bigint::wds, and Bigint::x.

Referenced by d2b(), diff(), i2b(), lshift(), mult(), multadd(), os_dtoa(), os_strtod(), rv_alloc(), and s2b().

static void Bfree | ( | Bigint * | v | ) | `[static]`

Definition at line 598 of file OSdtoa.cpp.

References ACQUIRE_DTOA_LOCK, FREE_DTOA_LOCK, and freelist.

Referenced by lshift(), multadd(), os_dtoa(), os_freedtoa(), os_strtod(), and pow5mult().

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

Definition at line 617 of file OSdtoa.cpp.

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

Referenced by os_dtoa(), pow5mult(), and s2b().

static Bigint* s2b | ( | CONST char * | s,
|  | int | nd0,
|  | int | nd,
|  | ULong | y9 |
| ) |  |  | `[static]`

Definition at line 674 of file OSdtoa.cpp.

References Balloc(), Bigint::k, Long, multadd(), Bigint::wds, and Bigint::x.

Referenced by os_strtod().

static int hi0bits | ( | register ULong | x | ) | `[static]`

Definition at line 712 of file OSdtoa.cpp.

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

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

static int lo0bits | ( | ULong * | y | ) | `[static]`

Definition at line 746 of file OSdtoa.cpp.

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

Referenced by d2b().

static Bigint* i2b | ( | int | i | ) | `[static]`

Definition at line 794 of file OSdtoa.cpp.

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

Referenced by os_dtoa(), os_strtod(), and pow5mult().

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

Definition at line 810 of file OSdtoa.cpp.

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

Referenced by getMult(), os_dtoa(), os_strtod(), pow5mult(), writeDblVectorData(), writeIntVectorData(), and OSiLWriter::writeOSiL().

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

Definition at line 922 of file OSdtoa.cpp.

References ACQUIRE_DTOA_LOCK, Bfree(), FREE_DTOA_LOCK, i2b(), mult(), multadd(), Bigint::next, and p5s.

Referenced by os_dtoa(), and os_strtod().

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

Definition at line 979 of file OSdtoa.cpp.

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

Referenced by os_dtoa(), and os_strtod().

static int cmp | ( | Bigint * | a,
|  | Bigint * | b |
| ) |  |  | `[static]`

Definition at line 1039 of file OSdtoa.cpp.

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

Referenced by diff(), os_dtoa(), os_strtod(), and quorem().

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

Definition at line 1073 of file OSdtoa.cpp.

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

Referenced by os_dtoa(), and os_strtod().

static double ulp | ( | double | x | ) | `[static]`

Definition at line 1167 of file OSdtoa.cpp.

References dval, Exp_mask, Exp_msk1, Exp_shift, Long, P, word0, word1, and Bigint::x.

Referenced by os_strtod().

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

Definition at line 1209 of file OSdtoa.cpp.

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

Referenced by ratio().

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

Definition at line 1279 of file OSdtoa.cpp.

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

Referenced by os_dtoa(), and os_strtod().

static double ratio | ( | Bigint * | a,
|  | Bigint * | b |
| ) |  |  | `[static]`

Definition at line 1417 of file OSdtoa.cpp.

References b2d(), dval, Exp_msk1, Bigint::wds, and word0.

Referenced by os_strtod().

static int match | ( | CONST char ** | sp,
|  | CONST char * | t |
| ) |  |  | `[static]`

Definition at line 1505 of file OSdtoa.cpp.

References CONST.

Referenced by os_strtod().

static void hexnan | ( | double * | rvp,
|  | CONST char ** | sp |
| ) |  |  | `[static]`

Definition at line 1527 of file OSdtoa.cpp.

References CONST, Exp_mask, word0, word1, and Bigint::x.

Referenced by os_strtod().

double os_strtod | ( | CONST char * | s00,
|  | char ** | se |
| ) |  |  |

Definition at line 1581 of file OSdtoa.cpp.

References Avoid_Underflow, Balloc(), Bcopy, Bfree(), Bias, Big0, Big1, bigtens, Bndry_mask, Bndry_mask1, cmp(), CONST, d2b(), diff(), dval, Emin, Exp_1, Exp_mask, Exp_msk1, Exp_shift, Flt_Rounds, Frac_mask, hexnan(), i2b(), IEEE_Arith, INFNAN_CHECK, Log2P, Long, LSB, lshift(), match(), mult(), n_bigtens, NAN_WORD0, NAN_WORD1, OSDBL_MAX, P, pow5mult(), ratio(), rounded_product, rounded_quotient, Rounding, s2b(), Scale_Bit, Bigint::sign, Ten_pmax, tens, Tiny0, Tiny1, ulp(), word0, and word1.

Referenced by getObjVal(), os_strtod_wrap(), IpoptSolver::setSolverOptions(), CouenneSolver::setSolverOptions(), CoinSolver::setSolverOptions(), and BonminSolver::setSolverOptions().

static int quorem | ( | Bigint * | b,
|  | Bigint * | S |
| ) |  |  | `[static]`

Definition at line 2473 of file OSdtoa.cpp.

References cmp(), FFFFFFFF, Storeinc, Bigint::wds, and Bigint::x.

Referenced by os_dtoa().

static char* rv_alloc | ( | int | i | ) | `[static]`

Definition at line 2594 of file OSdtoa.cpp.

References Balloc().

Referenced by nrv_alloc(), and os_dtoa().

static char* nrv_alloc | ( | CONST char * | s,
|  | char ** | rve,
|  | int | n |
| ) |  |  | `[static]`

Definition at line 2617 of file OSdtoa.cpp.

References rv_alloc().

Referenced by os_dtoa().

void os_freedtoa | ( | char * | s | ) |

Definition at line 2639 of file OSdtoa.cpp.

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

Referenced by os_dtoa(), and os_dtoa_format().

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

Definition at line 2691 of file OSdtoa.cpp.

References Balloc(), Bcopy, Bfree(), Bias, bigtens, Bletch, Bndry_mask, cmp(), d2b(), diff(), dval, Exp_11, Exp_mask, Exp_msk1, Exp_shift1, Flt_Rounds, Frac_mask, Frac_mask1, hi0bits(), i2b(), Int_max, Log2P, Long, lshift(), mult(), multadd(), n_bigtens, nrv_alloc(), os_freedtoa(), P, pow5mult(), Quick_max, quorem(), Rounding, rv_alloc(), Bigint::sign, Sign_bit, Ten_pmax, tens, Bigint::wds, word0, word1, and Bigint::x.

Referenced by os_dtoa_format().

## Variable Documentation

double private_mem[PRIVATE_mem]`[static]`

Definition at line 253 of file OSdtoa.cpp.

Referenced by Balloc().

double * pmem_next = private_mem`[static]`

Definition at line 253 of file OSdtoa.cpp.

Referenced by Balloc().

Bigint* freelist[Kmax+1]`[static]`

Definition at line 549 of file OSdtoa.cpp.

Referenced by Balloc(), and Bfree().

Bigint* p5s`[static]`

Definition at line 915 of file OSdtoa.cpp.

Referenced by pow5mult().

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 1454 of file OSdtoa.cpp.

Referenced by os_dtoa(), and os_strtod().

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

Definition at line 1465 of file OSdtoa.cpp.

Referenced by os_dtoa(), and os_strtod().

CONST double tinytens[]`[static]`

Initial value:

     { 1e-16, 1e-32, 1e-64, 1e-128,

                    9007199254740992.*9007199254740992.e-256

                    }

Definition at line 1466 of file OSdtoa.cpp.

char* dtoa_result`[static]`

Definition at line 2587 of file OSdtoa.cpp.