65 sprintf(s,
"%#.16E", d);
69 epos = strchr(pdst,
'E');
71 for (i = epos - dst; dst[i] !=
'\0'; i++) {
72 if (dst[i] ==
'0' || dst[i] ==
'+')
continue;
73 else pdst[0] = dst[i];
81 strcpy(dst, AFW_NUMBER_Q_EXPONENT_ZERO);
84 epos = strchr(s,
'E');
86 for (i = epos - s - 1; i > 0; i--) {
87 if (s[i] ==
'0')
continue;
90 else if (s[i] ==
'.') {
105 strcpy(s, AFW_NUMBER_Q_NAN);
106 }
else if (d <= DBL_MAX) {
107 strcpy(s, AFW_NUMBER_Q_NEGATIVE_INFINITY);
109 strcpy(s, AFW_NUMBER_Q_INFINITY);
118 impl_integer_len_as_u8(
143 AFW_DEFINE_STATIC_INLINE(
void)
144 impl_number_integer_set_u8(
158 *--s =
'0' + (i % 10);
176 result->len = impl_integer_len_as_u8(i);
178 impl_number_integer_set_u8(i, s, result->len, xctx);
193 needed = impl_integer_len_as_u8(i);
194 impl_number_integer_set_u8(i, s, needed, xctx);
218 if (is_double) *is_double =
false;
225 if (is_double) *is_double =
true;
226 return strlen(AFW_NUMBER_Q_INF);
231 if (is_double) *is_double =
true;
232 return strlen(AFW_NUMBER_Q_INFINITY);
237 if (is_double) *is_double =
true;
238 return strlen(AFW_NUMBER_Q_NEGATIVE_INF);
242 AFW_NUMBER_Q_NEGATIVE_INFINITY))
245 if (is_double) *is_double =
true;
246 return strlen(AFW_NUMBER_Q_NEGATIVE_INFINITY);
251 if (is_double) *is_double =
true;
252 return strlen(AFW_NUMBER_Q_NAN);
257 if (is_double) *is_double =
true;
258 return strlen(AFW_NUMBER_Q_NEGATIVE_NAN);
296 if (*c >=
'1' && *c <=
'9') {
299 negative = -((*c) -
'0');
302 while (len > 0 && *c >=
'0' && *c <=
'9') {
303 negative = (negative * 10) - ((*c) -
'0');
311 else if (*c ==
'0') {
334 if (len <= 0 || *c < '0' || *c >
'9') {
337 while (len > 0 && *c >=
'0' && *c <=
'9') {
356 if (*c ==
'e' || *c ==
'E') {
366 if (*c ==
'+' || *c ==
'-') {
371 if (len <= 0 || *c < '0' || *c >
'9') {
375 while (len > 0 && *c >=
'0' && *c <=
'9') {
389 if (is_double) *is_double =
false;
408 if (is_double) *is_double =
true;
414 number = strtod(s, NULL);
429 for (result = 1; i > 9; i /= 10) {
441 for (result = 1; i > 9; i /= 10) {
AFW_DEFINE(const afw_object_t *)
Adaptive Framework Core Internal.
#define AFW_UTF8_Z_LEN
String is NUL (0) terminate.
double afw_double_t
Normal AFW number is double.
#define AFW_INTEGER_Q_MIN
smallest afw_integer_t quoted
char afw_utf8_octet_t
8 bits of utf-8 codepoint.
apr_size_t afw_size_t
size_t.
#define AFW_INTEGER_MIN
smallest afw_integer_t
apr_int64_t afw_integer_t
typedef for big signed int.
afw_number_bytes_needed_size_t(afw_size_t i)
Determine bytes needed to hold printable size_t.
afw_boolean_t afw_number_is_NaN(double d)
Determine if double is not a number.
afw_boolean_t afw_number_is_finite(double d)
Determine if double is finite.
afw_number_parse(const afw_utf8_octet_t *cursor, afw_size_t len, afw_integer_t *i, afw_double_t *d, afw_boolean_t *is_double, const afw_pool_t *p, afw_xctx_t *xctx)
Parse an integer or double using specified pool for work area.
afw_number_integer_set_u8(afw_integer_t i, afw_utf8_octet_t *s, afw_size_t len, afw_xctx_t *xctx)
Convert an integer to u8 in supplied buffer.
afw_number_double_to_utf8(afw_double_t d, const afw_pool_t *p, afw_xctx_t *xctx)
Convert a double to utf8 in specified pool.
afw_number_bytes_needed_integer(afw_integer_t i)
Determine bytes needed to hold printable afw_integer_t.
afw_number_integer_to_utf8(afw_integer_t i, const afw_pool_t *p, afw_xctx_t *xctx)
Convert an integer to utf8 in specified pool.
#define afw_pool_calloc(instance, size, xctx)
Call method calloc of interface afw_pool.
#define afw_pool_get_apr_pool(instance)
Call method get_apr_pool of interface afw_pool.
#define afw_pool_calloc_type(instance, type, xctx)
Macro to allocate cleared memory to hold type in pool.
#define afw_utf8_create_copy(s, len, p, xctx)
Make a utf-8 sting from chars in pool specified.
afw_boolean_t afw_utf8_len_starts_with_z(const afw_utf8_octet_t *s1, afw_size_t len1, const afw_utf8_z_t *s2_z)
Returns true if series of bytes for len s1 starts with zero terminated string s2.
Interface afw_pool public struct.
NFC normalized UTF-8 string.
Interface afw_xctx public struct.