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

Go to the source code of this file.

Functions

void ULtod (ULong *L, const ULong *bits, Long exp, int k)
 
int strtord (CONST char *s, char **sp, int rounding, double *d)
 

Function Documentation

◆ strtord()

int strtord ( CONST char *  s,
char **  sp,
int  rounding,
double *  d 
)

Definition at line 86 of file strtord.c.

88 {
89  static FPI fpi0 = {53, 1 - 1023 - 53 + 1, 2046 - 1023 - 53 + 1, 1, SI};
90  FPI *fpi, fpi1;
91  ULong bits[2];
92  Long exp;
93  int k;
94 
95  fpi = &fpi0;
96  if(rounding != FPI_Round_near)
97  {
98  fpi1 = fpi0;
99  fpi1.rounding = rounding;
100  fpi = &fpi1;
101  }
102  k = strtodg(s, sp, fpi, &exp, bits);
103  ULtod((ULong*)d, bits, exp, k);
104  return k;
105 }
#define fpi1
#define SI
Definition: gdtoaimp.h:635
unsigned Long ULong
Definition: gdtoa.h:41
void ULtod(ULong *L, const ULong *bits, Long exp, int k)
Definition: strtord.c: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 fpi1, FPI_Round_near, Long, SI, strtodg(), and ULtod().

◆ ULtod()

void ULtod ( ULong L,
const ULong bits,
Long  exp,
int  k 
)

Definition at line 41 of file strtord.c.

43 {
44  switch(k & STRTOG_Retmask)
45  {
46  case STRTOG_NoNumber:
47  case STRTOG_Zero:
48  L[0] = L[1] = 0;
49  break;
50 
51  case STRTOG_Denormal:
52  L[_1] = bits[0];
53  L[_0] = bits[1];
54  break;
55 
56  case STRTOG_Normal:
57  case STRTOG_NaNbits:
58  L[_1] = bits[0];
59  L[_0] = (bits[1] & (unsigned)~0x100000) | (unsigned)((exp + 0x3ff + 52) << 20);
60  break;
61 
62  case STRTOG_Infinite:
63  L[_0] = 0x7ff00000;
64  L[_1] = 0;
65  break;
66 
67  case STRTOG_NaN:
68  L[0] = d_QNAN0;
69  L[1] = d_QNAN1;
70  }
71  if(k & STRTOG_Neg)
72  {
73  {
74  L[_0] |= 0x80000000L;
75  }
76  }
77 }

References STRTOG_Denormal, STRTOG_Infinite, STRTOG_NaN, STRTOG_NaNbits, STRTOG_Neg, STRTOG_NoNumber, STRTOG_Normal, STRTOG_Retmask, and STRTOG_Zero.

Referenced by strtod(), strtoId(), strtopd(), and strtord().