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

Go to the source code of this file.

Functions

void ULtox (UShort *L, const ULong *bits, Long exp, int k)
 
int strtorx (CONST char *s, char **sp, int rounding, void *L)
 

Function Documentation

◆ strtorx()

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

Definition at line 112 of file strtorx.c.

114 {
115  static FPI fpi0 = {64, 1 - 16383 - 64 + 1, 32766 - 16383 - 64 + 1, 1, SI};
116  FPI *fpi, fpi1;
117  ULong bits[2];
118  Long exp;
119  int k;
120 
121  fpi = &fpi0;
122  if(rounding != FPI_Round_near)
123  {
124  fpi1 = fpi0;
125  fpi1.rounding = rounding;
126  fpi = &fpi1;
127  }
128  k = strtodg(s, sp, fpi, &exp, bits);
129  ULtox((UShort*)L, bits, exp, k);
130  return k;
131 }
#define fpi1
void ULtox(UShort *L, const ULong *bits, Long exp, int k)
Definition: strtorx.c:61
unsigned short UShort
Definition: gdtoa.h:44
#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 fpi1, FPI_Round_near, Long, SI, strtodg(), and ULtox().

◆ ULtox()

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

Definition at line 61 of file strtorx.c.

63 {
64  switch(k & STRTOG_Retmask)
65  {
66  case STRTOG_NoNumber:
67  case STRTOG_Zero:
68  L[0] = L[1] = L[2] = L[3] = L[4] = 0;
69  break;
70 
71  case STRTOG_Denormal:
72  L[_0] = 0;
73  goto normal_bits;
74 
75  case STRTOG_Normal:
76  case STRTOG_NaNbits:
77  L[_0] = (UShort)(exp + 0x3fff + 63);
78  normal_bits:
79  L[_4] = (UShort)bits[0];
80  L[_3] = (UShort)(bits[0] >> 16);
81  L[_2] = (UShort)bits[1];
82  L[_1] = (UShort)(bits[1] >> 16);
83  break;
84 
85  case STRTOG_Infinite:
86  L[_0] = 0x7fff;
87  L[_1] = L[_2] = L[_3] = L[_4] = 0;
88  break;
89 
90  case STRTOG_NaN:
91  L[0] = ldus_QNAN0;
92  L[1] = ldus_QNAN1;
93  L[2] = ldus_QNAN2;
94  L[3] = ldus_QNAN3;
95  L[4] = ldus_QNAN4;
96  }
97  if(k & STRTOG_Neg)
98  {
99  {
100  L[_0] |= 0x8000;
101  }
102  }
103 }
unsigned short UShort
Definition: gdtoa.h:44

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

Referenced by strtoIx(), and strtorx().