#include "OSConfig.h"#include "OSdtoa.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, 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 (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 IEEE_8087 |
| #define INFNAN_CHECK |
| #define NO_LONG_LONG |
Definition at line 189 of file OSdtoa.cpp.
| #define Just_16 |
Definition at line 190 of file OSdtoa.cpp.
| #define Long int |
| #define Intcast (int)(long) |
| #define MALLOC malloc |
| #define PRIVATE_MEM 2304 |
Definition at line 248 of file OSdtoa.cpp.
| #define PRIVATE_mem ((PRIVATE_MEM+sizeof(double)-1)/sizeof(double)) |
| #define IEEE_Arith |
| #define INFNAN_CHECK |
Definition at line 266 of file OSdtoa.cpp.
| #define CONST const |
Definition at line 340 of file OSdtoa.cpp.
Referenced by b2d(), d2b(), hexnan(), os_dtoa(), os_strtod(), ratio(), and ulp().
Definition at line 341 of file OSdtoa.cpp.
Referenced by b2d(), d2b(), hexnan(), os_dtoa(), os_strtod(), and ulp().
Definition at line 346 of file OSdtoa.cpp.
Referenced by b2d(), os_dtoa(), os_strtod(), ratio(), and ulp().
| #define Exp_shift 20 |
| #define Exp_shift1 20 |
| #define Exp_msk1 0x100000 |
Definition at line 370 of file OSdtoa.cpp.
Referenced by d2b(), os_dtoa(), os_strtod(), ratio(), and ulp().
| #define Exp_msk11 0x100000 |
| #define Exp_mask 0x7ff00000 |
Definition at line 372 of file OSdtoa.cpp.
Referenced by hexnan(), os_dtoa(), os_strtod(), and ulp().
| #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 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 |
Definition at line 530 of file OSdtoa.cpp.
| #define Bcopy | ( | x, | |||
| y | ) |
Value:
Definition at line 605 of file OSdtoa.cpp.
Referenced by multadd(), os_dtoa(), and os_strtod().
| #define d0 word0(d) |
| #define d1 word1(d) |
| #define Scale_Bit 0x10 |
| #define n_bigtens 5 |
| #define NAN_WORD0 0x7ff80000 |
| #define NAN_WORD1 0 |
| 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 221 of file OSdtoa.cpp.
Definition at line 545 of file OSdtoa.cpp.
| static Bigint* Balloc | ( | int | k | ) | [static] |
Definition at line 554 of file OSdtoa.cpp.
References ACQUIRE_DTOA_LOCK, FREE_DTOA_LOCK, freelist, Bigint::k, k, MALLOC, Bigint::maxwds, Bigint::next, pmem_next, PRIVATE_mem, private_mem, Bigint::sign, Bigint::wds, and 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 594 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().
Definition at line 613 of file OSdtoa.cpp.
References Balloc(), Bcopy, Bfree(), FFFFFFFF, Bigint::k, Bigint::maxwds, Bigint::wds, Bigint::x, and x.
Referenced by os_dtoa(), pow5mult(), and s2b().
Definition at line 670 of file OSdtoa.cpp.
References Balloc(), k, Long, multadd(), Bigint::wds, Bigint::x, and x.
Referenced by os_strtod().
| static int hi0bits | ( | register ULong | x | ) | [static] |
| static int lo0bits | ( | ULong * | y | ) | [static] |
| static Bigint* i2b | ( | int | i | ) | [static] |
Definition at line 790 of file OSdtoa.cpp.
References Balloc(), Bigint::wds, and Bigint::x.
Referenced by os_dtoa(), os_strtod(), and pow5mult().
Definition at line 806 of file OSdtoa.cpp.
References a, Balloc(), c, FFFFFFFF, k, Storeinc, Bigint::wds, Bigint::x, and x.
Referenced by os_dtoa(), os_strtod(), and pow5mult().
Definition at line 918 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().
Definition at line 975 of file OSdtoa.cpp.
References Balloc(), Bfree(), Bigint::k, Bigint::maxwds, n, Bigint::wds, Bigint::x, and x.
Referenced by os_dtoa(), and os_strtod().
Definition at line 1035 of file OSdtoa.cpp.
References a, Bigint::wds, and Bigint::x.
Referenced by diff(), os_dtoa(), os_strtod(), and quorem().
Definition at line 1069 of file OSdtoa.cpp.
References a, Balloc(), c, cmp(), FFFFFFFF, Storeinc, Bigint::wds, and Bigint::x.
Referenced by Bonmin::IpoptWarmStart::generateDiff(), Bonmin::FilterWarmStart::generateDiff(), os_dtoa(), and os_strtod().
| static double ulp | ( | double | x | ) | [static] |
| static double b2d | ( | Bigint * | a, | |
| int * | e | |||
| ) | [static] |
| static Bigint* d2b | ( | double | d, | |
| int * | e, | |||
| int * | bits | |||
| ) | [static] |
Definition at line 1413 of file OSdtoa.cpp.
References a, b2d(), dval, Exp_msk1, Bigint::wds, and word0.
Referenced by os_strtod().
| static int match | ( | CONST char ** | sp, | |
| char * | t | |||
| ) | [static] |
| static void hexnan | ( | double * | rvp, | |
| CONST char ** | sp | |||
| ) | [static] |
Definition at line 1523 of file OSdtoa.cpp.
References c, CONST, Exp_mask, word0, word1, and x.
Referenced by os_strtod().
| double os_strtod | ( | CONST char * | s00, | |
| char ** | se | |||
| ) |
Definition at line 1577 of file OSdtoa.cpp.
References Avoid_Underflow, Balloc(), Bcopy, Bfree(), Bias, Big0, Big1, bigtens, Bndry_mask, Bndry_mask1, c, 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, 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(), and os_strtod_wrap().
Definition at line 2468 of file OSdtoa.cpp.
References cmp(), FFFFFFFF, n, Storeinc, Bigint::wds, and Bigint::x.
Referenced by os_dtoa().
| static char* rv_alloc | ( | int | i | ) | [static] |
| static char* nrv_alloc | ( | char * | s, | |
| char ** | rve, | |||
| int | n | |||
| ) | [static] |
| void os_freedtoa | ( | char * | s | ) |
Definition at line 2634 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 2686 of file OSdtoa.cpp.
References Balloc(), Bcopy, Bfree(), Bias, bigtens, Bletch, Bndry_mask, cmp(), d2b(), diff(), dval, eps, Exp_11, Exp_mask, Exp_msk1, Exp_shift1, Flt_Rounds, Frac_mask, Frac_mask1, hi0bits(), i2b(), Int_max, Log2P, Long, lshift(), m2, 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, Bigint::x, and x.
Referenced by os_dtoa_format().
double private_mem[PRIVATE_mem] [static] |
double * pmem_next = private_mem [static] |
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 1450 of file OSdtoa.cpp.
Referenced by os_dtoa(), and os_strtod().
CONST double bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 } [static] |
CONST double tinytens[] [static] |
Initial value:
Definition at line 1462 of file OSdtoa.cpp.
char* dtoa_result [static] |
Definition at line 2582 of file OSdtoa.cpp.
1.4.7