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

Go to the source code of this file.

Functions

int strtopf (CONST char *s, char **sp, float *f)
 

Function Documentation

◆ strtopf()

int strtopf ( CONST char *  s,
char **  sp,
float *  f 
)

Definition at line 40 of file strtopf.c.

42 {
43  static FPI fpi = {24, 1 - 127 - 24 + 1, 254 - 127 - 24 + 1, 1, SI};
44  ULong bits[1], *L;
45  Long exp;
46  int k;
47 
48  k = strtodg(s, sp, &fpi, &exp, bits);
49  L = (ULong*)f;
50  switch(k & STRTOG_Retmask)
51  {
52  case STRTOG_NoNumber:
53  case STRTOG_Zero:
54  L[0] = 0;
55  break;
56 
57  case STRTOG_Normal:
58  case STRTOG_NaNbits:
59  L[0] = (bits[0] & 0x7fffff) | (unsigned)((exp + 0x7f + 23) << 23);
60  break;
61 
62  case STRTOG_Denormal:
63  L[0] = bits[0];
64  break;
65 
66  case STRTOG_Infinite:
67  L[0] = 0x7f800000;
68  break;
69 
70  case STRTOG_NaN:
71  L[0] = f_QNAN;
72  }
73  if(k & STRTOG_Neg)
74  {
75  {
76  L[0] |= 0x80000000L;
77  }
78  }
79  return k;
80 }
#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.