Scale down 'val', returns 'updated val' and 'x', such that val*base^X = original val Similar to "frexpl(3)" but without requiring 'libm', allowing only integer scale, limited functionality and error checking. */
| 356 | Similar to "frexpl(3)" but without requiring 'libm', |
| 357 | allowing only integer scale, limited functionality and error checking. */ |
| 358 | static long double |
| 359 | expld (long double val, int base, int /*output */ *x) |
| 360 | { |
| 361 | int power = 0; |
| 362 | |
| 363 | if (val >= -LDBL_MAX && val <= LDBL_MAX) |
| 364 | { |
| 365 | while (absld (val) >= base) |
| 366 | { |
| 367 | ++power; |
| 368 | val /= base; |
| 369 | } |
| 370 | } |
| 371 | if (x) |
| 372 | *x = power; |
| 373 | return val; |
| 374 | } |
| 375 | |
| 376 | /* EXTREMELY limited 'ceil' - without 'libm'. |
| 377 | Assumes values that fit in intmax_t. */ |
no test coverage detected