Embedded Artistry libc
C Standard Library Support for Bare-metal Systems
strtodnrp.c File Reference
#include "gdtoaimp.h"
Include dependency graph for strtodnrp.c:

Go to the source code of this file.

Functions

double strtod (CONST char *s, char **sp)
 

Function Documentation

◆ strtod()

double strtod ( CONST char *  s,
char **  sp 
)

Definition at line 45 of file strtodnrp.c.

47 {
48  static FPI fpi = {53, 1 - 1023 - 53 + 1, 2046 - 1023 - 53 + 1, 1, SI};
49  ULong bits[2];
50  Long exp;
51  int k;
52  union
53  {
54  ULong L[2];
55  double d;
56  } u;
57 
58  k = strtodg(s, sp, &fpi, &exp, bits);
59  switch(k & STRTOG_Retmask)
60  {
61  case STRTOG_NoNumber:
62  case STRTOG_Zero:
63  u.L[0] = u.L[1] = 0;
64  break;
65 
66  case STRTOG_Normal:
67  u.L[_1] = bits[0];
68  u.L[_0] = (bits[1] & ~0x100000) | ((exp + 0x3ff + 52) << 20);
69  break;
70 
71  case STRTOG_Denormal:
72  u.L[_1] = bits[0];
73  u.L[_0] = bits[1];
74  break;
75 
76  case STRTOG_Infinite:
77  u.L[_0] = 0x7ff00000;
78  u.L[_1] = 0;
79  break;
80 
81  case STRTOG_NaN:
82  u.L[0] = d_QNAN0;
83  u.L[1] = d_QNAN1;
84  break;
85 
86  case STRTOG_NaNbits:
87  u.L[_0] = 0x7ff00000 | bits[1];
88  u.L[_1] = bits[0];
89  }
90  if(k & STRTOG_Neg)
91  u.L[_0] |= 0x80000000L;
92  return u.d;
93 }
#define SI
Definition: gdtoaimp.h:635
unsigned Long ULong
Definition: gdtoa.h:41
Definition: gdtoa.h:86
#define Long
Definition: gdtoa.h:38
int strtodg(CONST char *s00, char **se, FPI *fpi, Long *exp, ULong *bits)
Definition: strtodg.c:443

References Long, SI, strtodg(), STRTOG_Denormal, STRTOG_Infinite, STRTOG_NaN, STRTOG_NaNbits, STRTOG_Neg, STRTOG_NoNumber, STRTOG_Normal, STRTOG_Retmask, and STRTOG_Zero.