Lines Matching +full:- +full:e
4 * SPDX-License-Identifier: Apache-2.0
26 int32_t e = -1, v, f = 0; in lwm2m_float_to_b32() local
28 int32_t val2 = (*in - (int32_t)*in) * PRECISION32; in lwm2m_float_to_b32()
32 return -EINVAL; in lwm2m_float_to_b32()
53 e++; in lwm2m_float_to_b32()
60 i = e; in lwm2m_float_to_b32()
63 if (!f && e < 0 && v < PRECISION32) { in lwm2m_float_to_b32()
64 /* handle -e */ in lwm2m_float_to_b32()
65 e--; in lwm2m_float_to_b32()
68 v -= PRECISION32; in lwm2m_float_to_b32()
69 f |= 1 << (22 - i); in lwm2m_float_to_b32()
80 e += 127; in lwm2m_float_to_b32()
91 /* exponent: bits 30-23 */ in lwm2m_float_to_b32()
92 b32[0] |= e >> 1; in lwm2m_float_to_b32()
93 b32[1] = (e & 1) << 7; in lwm2m_float_to_b32()
95 /* fraction: bits 22-0 */ in lwm2m_float_to_b32()
108 int32_t e = -1; in lwm2m_float_to_b64() local
110 int64_t val2 = (*in - (int64_t)*in) * PRECISION64; in lwm2m_float_to_b64()
114 return -EINVAL; in lwm2m_float_to_b64()
135 e++; in lwm2m_float_to_b64()
142 i = e; in lwm2m_float_to_b64()
145 if (!f && e < 0 && v < PRECISION64) { in lwm2m_float_to_b64()
146 /* handle -e */ in lwm2m_float_to_b64()
147 e--; in lwm2m_float_to_b64()
150 v -= PRECISION64; in lwm2m_float_to_b64()
151 f |= (int64_t)1 << (51 - i); in lwm2m_float_to_b64()
162 e += 1023; in lwm2m_float_to_b64()
173 /* exponent: bits 62-52 */ in lwm2m_float_to_b64()
174 b64[0] |= (e >> 4); in lwm2m_float_to_b64()
175 b64[1] = ((e & 0xF) << 4); in lwm2m_float_to_b64()
177 /* fraction: bits 51-0 */ in lwm2m_float_to_b64()
193 int32_t f, k, i, e; in lwm2m_b32_to_float() local
198 return -EINVAL; in lwm2m_b32_to_float()
207 /* calc exponent: bits 30-23 */ in lwm2m_b32_to_float()
208 e = SHIFT_LEFT(b32[0], 1, 0xFF); in lwm2m_b32_to_float()
209 e += SHIFT_RIGHT(b32[1], 7, 0x1); in lwm2m_b32_to_float()
211 e -= 127; in lwm2m_b32_to_float()
215 /* calc fraction: bits 22-0 */ in lwm2m_b32_to_float()
221 if (e > -1) { in lwm2m_b32_to_float()
223 if (e > 23) { in lwm2m_b32_to_float()
224 e = 23; in lwm2m_b32_to_float()
227 val1 = (f >> (23 - e)) * (sign ? -1 : 1); in lwm2m_b32_to_float()
233 /* account for -e */ in lwm2m_b32_to_float()
234 while (e < -1) { in lwm2m_b32_to_float()
236 e++; in lwm2m_b32_to_float()
239 for (i = 22 - e; i >= 0; i--) { in lwm2m_b32_to_float()
248 *out = (double)val1 - (double)val2 / PRECISION32; in lwm2m_b32_to_float()
260 int i, e; in lwm2m_b64_to_float() local
265 return -EINVAL; in lwm2m_b64_to_float()
274 /* get exponent: bits 62-52 */ in lwm2m_b64_to_float()
275 e = SHIFT_LEFT((uint16_t)b64[0], 4, 0x7F0); in lwm2m_b64_to_float()
276 e += SHIFT_RIGHT(b64[1], 4, 0xF); in lwm2m_b64_to_float()
278 e -= 1023; in lwm2m_b64_to_float()
282 /* get fraction: bits 51-0 */ in lwm2m_b64_to_float()
292 if (e > -1) { in lwm2m_b64_to_float()
294 if (e > 52) { in lwm2m_b64_to_float()
295 e = 52; in lwm2m_b64_to_float()
298 val1 = (f >> (52 - e)) * (sign ? -1 : 1); in lwm2m_b64_to_float()
304 /* account for -e */ in lwm2m_b64_to_float()
305 while (e < -1) { in lwm2m_b64_to_float()
307 e++; in lwm2m_b64_to_float()
310 for (i = 51 - e; i >= 0; i--) { in lwm2m_b64_to_float()
319 *out = (double)val1 - (double)val2 / PRECISION64; in lwm2m_b64_to_float()
335 return -EINVAL; in lwm2m_atof()
338 strncpy(buf, input, sizeof(buf) - 1); in lwm2m_atof()
339 buf[sizeof(buf) - 1] = '\0'; in lwm2m_atof()
341 if (strchr(buf, '-')) { in lwm2m_atof()
342 sign = -1; in lwm2m_atof()
353 return -EINVAL; in lwm2m_atof()
365 val2 = val2 * 10 + (*pos - '0'); in lwm2m_atof()
373 return !*pos || base == 1 ? 0 : -EINVAL; in lwm2m_atof()
381 int64_t val2 = (*input - (int64_t)*input) * PRECISION64; in lwm2m_ftoa()
397 dec_limit--; in lwm2m_ftoa()
409 val1--; in lwm2m_ftoa()
417 while (len > 1U && buf[len - 1] == '0') { in lwm2m_ftoa()
418 buf[--len] = '\0'; in lwm2m_ftoa()
424 (val1 == 0 && val2 < 0) ? "-" : "", (long long)val1, buf); in lwm2m_ftoa()
432 /* we should get a value first - consume all numbers */ in lwm2m_atou16()
434 val = val * 10U + (buf[pos] - '0'); in lwm2m_atou16()
446 int i, tokstart = -1, toklen; in lwm2m_string_to_path()
447 int end_index = strlen(pathstr) - 1; in lwm2m_string_to_path()
452 if (tokstart == -1) { in lwm2m_string_to_path()
462 toklen = i - tokstart + 1; in lwm2m_string_to_path()
466 toklen--; in lwm2m_string_to_path()
475 path->level++; in lwm2m_string_to_path()
476 switch (path->level) { in lwm2m_string_to_path()
478 path->obj_id = value; in lwm2m_string_to_path()
482 path->obj_inst_id = value; in lwm2m_string_to_path()
486 path->res_id = value; in lwm2m_string_to_path()
490 path->res_inst_id = value; in lwm2m_string_to_path()
494 return -EINVAL; in lwm2m_string_to_path()
498 tokstart = -1; in lwm2m_string_to_path()
507 uint8_t level = a->level; in lwm2m_obj_path_equal()
509 if (a->level != b->level) { in lwm2m_obj_path_equal()
513 if (level >= LWM2M_PATH_LEVEL_OBJECT && (a->obj_id != b->obj_id)) { in lwm2m_obj_path_equal()
517 if (level >= LWM2M_PATH_LEVEL_OBJECT_INST && (a->obj_inst_id != b->obj_inst_id)) { in lwm2m_obj_path_equal()
521 if (level >= LWM2M_PATH_LEVEL_RESOURCE && (a->res_id != b->res_id)) { in lwm2m_obj_path_equal()
525 if (level >= LWM2M_PATH_LEVEL_RESOURCE_INST && (a->res_inst_id != b->res_inst_id)) { in lwm2m_obj_path_equal()
537 if (addr->sa_family == AF_INET6) { in lwm2m_sprint_ip_addr()
538 return net_addr_ntop(AF_INET6, &net_sin6(addr)->sin6_addr, buf, sizeof(buf)); in lwm2m_sprint_ip_addr()
541 if (addr->sa_family == AF_INET) { in lwm2m_sprint_ip_addr()
542 return net_addr_ntop(AF_INET, &net_sin(addr)->sin_addr, buf, sizeof(buf)); in lwm2m_sprint_ip_addr()
551 return digit - 10U + 'a'; in to_hex_digit()
565 tkl = MIN(tkl, sizeof(buf) / 2 - 1); in sprint_token()
574 strcpy(buf, "[no-token]"); in sprint_token()