blob: d8fa1d9e8db9d4ab8a3aefcf049eef1ebb6f05e3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#include "lib.h"
#include "compat/id-files-stat.c"
#include "compat/mmap-blob.c"
#include <floatingpoint.h>
#include <limits.h>
#include <errno.h>
long double string_to_ld(const char *str, char **endptr)
{
long double res;
decimal_record dr;
enum decimal_string_form form;
decimal_mode dm;
fp_exception_field_type excp;
char *echar;
string_to_decimal ((char **)&str, INT_MAX, 0,
&dr, &form, &echar);
if (endptr) *endptr = (char *)str;
if (form == invalid_form) {
errno = EINVAL;
return 0.0;
}
dm.rd = fp_nearest;
decimal_to_quadruple (&res, &dm, &dr, &excp);
if (excp & ((1 << fp_overflow) | (1 << fp_underflow)))
errno = ERANGE;
return res;
}
|