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

Go to the source code of this file.

Functions

void ULtoQ (ULong *L, const ULong *bits, Long exp, int k)
 
int strtorQ (CONST char *s, char **sp, int rounding, void *L)
 

Function Documentation

◆ strtorQ()

int strtorQ ( CONST char *  s,
char **  sp,
int  rounding,
void *  L 
)

Definition at line 110 of file strtorQ.c.

112 {
113  static FPI fpi0 = {113, 1 - 16383 - 113 + 1, 32766 - 16383 - 113 + 1, 1, SI};
114  FPI *fpi, fpi1;
115  ULong bits[4];
116  Long exp;
117  int k;
118 
119  fpi = &fpi0;
120  if(rounding != FPI_Round_near)
121  {
122  fpi1 = fpi0;
123  fpi1.rounding = rounding;
124  fpi = &fpi1;
125  }
126  k = strtodg(s, sp, fpi, &exp, bits);
127  ULtoQ((ULong*)L, bits, exp, k);
128  return k;
129 }
#define fpi1
#define SI
Definition: gdtoaimp.h:635
unsigned Long ULong
Definition: gdtoa.h:41
void ULtoQ(ULong *L, const ULong *bits, Long exp, int k)
Definition: strtorQ.c:59
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 ULtoQ().

◆ ULtoQ()

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

Definition at line 59 of file strtorQ.c.

61 {
62  switch(k & STRTOG_Retmask)
63  {
64  case STRTOG_NoNumber:
65  case STRTOG_Zero:
66  L[0] = L[1] = L[2] = L[3] = 0;
67  break;
68 
69  case STRTOG_Normal:
70  case STRTOG_NaNbits:
71  L[_3] = bits[0];
72  L[_2] = bits[1];
73  L[_1] = bits[2];
74  L[_0] = (bits[3] & (unsigned)~0x10000) | (unsigned)((exp + 0x3fff + 112) << 16);
75  break;
76 
77  case STRTOG_Denormal:
78  L[_3] = bits[0];
79  L[_2] = bits[1];
80  L[_1] = bits[2];
81  L[_0] = bits[3];
82  break;
83 
84  case STRTOG_Infinite:
85  L[_0] = 0x7fff0000;
86  L[_1] = L[_2] = L[_3] = 0;
87  break;
88 
89  case STRTOG_NaN:
90  L[0] = ld_QNAN0;
91  L[1] = ld_QNAN1;
92  L[2] = ld_QNAN2;
93  L[3] = ld_QNAN3;
94  }
95  if(k & STRTOG_Neg)
96  {
97  {
98  L[_0] |= 0x80000000L;
99  }
100  }
101 }

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

Referenced by strtoIQ(), and strtorQ().