Ruby  2.7.2p137(2020-10-01revision5445e0435260b449decf2ac16f9d09bae3cafe72)
Data Structures | Macros | Typedefs | Functions
dtoa.c File Reference
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>

Go to the source code of this file.

Data Structures

union  U
 
struct  Bigint
 

Macros

#define IEEE_LITTLE_ENDIAN
 
#define NO_LONG_LONG
 
#define MALLOC   xmalloc
 
#define FREE   xfree
 
#define PRIVATE_MEM   2304
 
#define PRIVATE_mem   ((PRIVATE_MEM+sizeof(double)-1)/sizeof(double))
 
#define IEEE_Arith
 
#define word0(x)   ((x).L[1])
 
#define word1(x)   ((x).L[0])
 
#define dval(x)   ((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 Pack_32
 
#define FFFFFFFF   0xffffffffUL
 
#define MULTIPLE_THREADS   1
 
#define ACQUIRE_DTOA_LOCK(n)   /*unused right now*/
 
#define FREE_DTOA_LOCK(n)   /*unused right now*/
 
#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 rv_alloc(i)   xmalloc(i)
 
#define rv_strdup(s, rve)   nrv_alloc((s), (rve), strlen(s)+1)
 
#define DBL_MANH_SIZE   20
 
#define DBL_MANL_SIZE   32
 
#define DBL_ADJ   (DBL_MAX_EXP - 2)
 
#define SIGFIGS   ((DBL_MANT_DIG + 3) / 4 + 1)
 
#define dexp_get(u)   ((int)(word0(u) >> Exp_shift) & ~Exp_msk1)
 
#define dexp_set(u, v)   (word0(u) = (((int)(word0(u)) & ~Exp_mask) | ((v) << Exp_shift)))
 
#define dmanh_get(u)   ((uint32_t)(word0(u) & Frac_mask))
 
#define dmanl_get(u)   ((uint32_t)word1(u))
 

Typedefs

typedef U double_u
 
typedef struct Bigint Bigint
 

Functions

 NO_SANITIZE ("unsigned-integer-overflow", static Bigint *diff(Bigint *a, Bigint *b))
 
 NO_SANITIZE ("unsigned-integer-overflow", double strtod(const char *s00, char **se))
 
double strtod (const char *s00, char **se)
 
 NO_SANITIZE ("unsigned-integer-overflow", static int quorem(Bigint *b, Bigint *S))
 
chardtoa (double d_, int mode, int ndigits, int *decpt, int *sign, char **rve)
 
charhdtoa (double d, const char *xdigs, int ndigits, int *decpt, int *sign, char **rve)
 

Macro Definition Documentation

◆ ACQUIRE_DTOA_LOCK

#define ACQUIRE_DTOA_LOCK (   n)    /*unused right now*/

Definition at line 488 of file dtoa.c.

◆ Avoid_Underflow

#define Avoid_Underflow

Definition at line 358 of file dtoa.c.

◆ Bcopy

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

Definition at line 554 of file dtoa.c.

◆ Bias

#define Bias   1023

Definition at line 339 of file dtoa.c.

◆ Big0

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

Definition at line 454 of file dtoa.c.

◆ Big1

#define Big1   0xffffffff

Definition at line 455 of file dtoa.c.

◆ Bletch

#define Bletch   0x10

Definition at line 347 of file dtoa.c.

◆ Bndry_mask

#define Bndry_mask   0xfffff

Definition at line 348 of file dtoa.c.

◆ Bndry_mask1

#define Bndry_mask1   0xfffff

Definition at line 349 of file dtoa.c.

◆ d0 [1/2]

#define d0   word0(d)

◆ d0 [2/2]

#define d0   word0(d)

◆ d1 [1/2]

#define d1   word1(d)

◆ d1 [2/2]

#define d1   word1(d)

◆ DBL_ADJ

#define DBL_ADJ   (DBL_MAX_EXP - 2)

Definition at line 3301 of file dtoa.c.

◆ DBL_MANH_SIZE

#define DBL_MANH_SIZE   20

Definition at line 3299 of file dtoa.c.

◆ DBL_MANL_SIZE

#define DBL_MANL_SIZE   32

Definition at line 3300 of file dtoa.c.

◆ dexp_get

#define dexp_get (   u)    ((int)(word0(u) >> Exp_shift) & ~Exp_msk1)

Definition at line 3303 of file dtoa.c.

◆ dexp_set

#define dexp_set (   u,
  v 
)    (word0(u) = (((int)(word0(u)) & ~Exp_mask) | ((v) << Exp_shift)))

Definition at line 3304 of file dtoa.c.

◆ dmanh_get

#define dmanh_get (   u)    ((uint32_t)(word0(u) & Frac_mask))

Definition at line 3305 of file dtoa.c.

◆ dmanl_get

#define dmanl_get (   u)    ((uint32_t)word1(u))

Definition at line 3306 of file dtoa.c.

◆ dval

#define dval (   x)    ((x).d)

Definition at line 311 of file dtoa.c.

◆ Ebits

#define Ebits   11

Definition at line 343 of file dtoa.c.

◆ Emin

#define Emin   (-1022)

Definition at line 340 of file dtoa.c.

◆ Exp_1

#define Exp_1   0x3ff00000

Definition at line 341 of file dtoa.c.

◆ Exp_11

#define Exp_11   0x3ff00000

Definition at line 342 of file dtoa.c.

◆ Exp_mask

#define Exp_mask   0x7ff00000

Definition at line 337 of file dtoa.c.

◆ Exp_msk1

#define Exp_msk1   0x100000

Definition at line 335 of file dtoa.c.

◆ Exp_msk11

#define Exp_msk11   0x100000

Definition at line 336 of file dtoa.c.

◆ Exp_shift

#define Exp_shift   20

Definition at line 333 of file dtoa.c.

◆ Exp_shift1

#define Exp_shift1   20

Definition at line 334 of file dtoa.c.

◆ FFFFFFFF

#define FFFFFFFF   0xffffffffUL

Definition at line 461 of file dtoa.c.

◆ Flt_Rounds

#define Flt_Rounds   1

Definition at line 368 of file dtoa.c.

◆ Frac_mask

#define Frac_mask   0xfffff

Definition at line 344 of file dtoa.c.

◆ Frac_mask1

#define Frac_mask1   0xfffff

Definition at line 345 of file dtoa.c.

◆ FREE

#define FREE   xfree

Definition at line 220 of file dtoa.c.

◆ FREE_DTOA_LOCK

#define FREE_DTOA_LOCK (   n)    /*unused right now*/

Definition at line 489 of file dtoa.c.

◆ IEEE_Arith

#define IEEE_Arith

Definition at line 237 of file dtoa.c.

◆ IEEE_LITTLE_ENDIAN

#define IEEE_LITTLE_ENDIAN

Definition at line 169 of file dtoa.c.

◆ Int_max

#define Int_max   14

Definition at line 356 of file dtoa.c.

◆ Kmax

#define Kmax   15

Definition at line 492 of file dtoa.c.

◆ Log2P

#define Log2P   1

Definition at line 352 of file dtoa.c.

◆ LSB

#define LSB   1

Definition at line 350 of file dtoa.c.

◆ MALLOC

#define MALLOC   xmalloc

Definition at line 215 of file dtoa.c.

◆ MULTIPLE_THREADS

#define MULTIPLE_THREADS   1

Definition at line 482 of file dtoa.c.

◆ n_bigtens

#define n_bigtens   5

Definition at line 1350 of file dtoa.c.

◆ NO_LONG_LONG

#define NO_LONG_LONG

Definition at line 197 of file dtoa.c.

◆ P

#define P   53

Definition at line 338 of file dtoa.c.

◆ Pack_32

#define Pack_32

Definition at line 458 of file dtoa.c.

◆ PRIVATE_MEM

#define PRIVATE_MEM   2304

Definition at line 225 of file dtoa.c.

◆ PRIVATE_mem

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

Definition at line 227 of file dtoa.c.

◆ Quick_max

#define Quick_max   14

Definition at line 355 of file dtoa.c.

◆ rounded_product

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

Definition at line 450 of file dtoa.c.

◆ rounded_quotient

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

Definition at line 451 of file dtoa.c.

◆ Rounding

#define Rounding   Flt_Rounds

Definition at line 377 of file dtoa.c.

◆ rv_alloc

#define rv_alloc (   i)    xmalloc(i)

Definition at line 2526 of file dtoa.c.

◆ rv_strdup

#define rv_strdup (   s,
  rve 
)    nrv_alloc((s), (rve), strlen(s)+1)

Definition at line 2541 of file dtoa.c.

◆ Scale_Bit

#define Scale_Bit   0x10

Definition at line 1349 of file dtoa.c.

◆ SIGFIGS

#define SIGFIGS   ((DBL_MANT_DIG + 3) / 4 + 1)

Definition at line 3302 of file dtoa.c.

◆ Sign_bit

#define Sign_bit   0x80000000

Definition at line 351 of file dtoa.c.

◆ Storeinc

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

Definition at line 319 of file dtoa.c.

◆ Ten_pmax

#define Ten_pmax   22

Definition at line 346 of file dtoa.c.

◆ Tiny0

#define Tiny0   0

Definition at line 353 of file dtoa.c.

◆ Tiny1

#define Tiny1   1

Definition at line 354 of file dtoa.c.

◆ word0

#define word0 (   x)    ((x).L[1])

Definition at line 305 of file dtoa.c.

◆ word1

#define word1 (   x)    ((x).L[0])

Definition at line 306 of file dtoa.c.

Typedef Documentation

◆ Bigint

typedef struct Bigint Bigint

Definition at line 303 of file dtoa.c.

◆ double_u

typedef U double_u

Definition at line 303 of file dtoa.c.

Function Documentation

◆ dtoa()

char* dtoa ( double  d_,
int  mode,
int  ndigits,
int decpt,
int sign,
char **  rve 
)

Definition at line 2596 of file dtoa.c.

References dval, Exp_mask, i, j1(), Bigint::k, L, rv_strdup, S, s2, Bigint::sign, Sign_bit, word0, word1, and Bigint::x.

◆ hdtoa()

char* hdtoa ( double  d,
const char xdigs,
int  ndigits,
int decpt,
int sign,
char **  rve 
)

Definition at line 3334 of file dtoa.c.

References U::d, INT_MAX, isinf, rv_strdup, Bigint::sign, Sign_bit, and word0.

◆ NO_SANITIZE() [1/3]

NO_SANITIZE ( "unsigned-integer-overflow"  ,
double   strtodconst char *s00, char **se 
)

◆ NO_SANITIZE() [2/3]

NO_SANITIZE ( "unsigned-integer-overflow"  ,
static Bigint diffBigint *a, Bigint *b 
)

◆ NO_SANITIZE() [3/3]

NO_SANITIZE ( "unsigned-integer-overflow"  ,
static int   quoremBigint *b, Bigint *S 
)

◆ strtod()

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

Definition at line 1445 of file dtoa.c.

References abs(), DBL_DIG, dval, errno, hexdigit, i, int, ISDIGIT, Bigint::k, L, ldexp(), NULL, s2, Bigint::sign, and strchr().

short
#define short
Definition: rb_mjit_min_header-2.7.2.h:2885
memcpy
void * memcpy(void *__restrict, const void *__restrict, size_t)