diff options
author | Jakob Kaivo <jkk@ung.org> | 2019-02-08 18:42:39 -0500 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2019-02-08 18:42:39 -0500 |
commit | 7ef8a7379f7f7d09e71ccae2a0b688c3cd80423f (patch) | |
tree | 092ab0aed1769117fd7b28b8592f6f96b0e0d5af /src/math/frexp.c | |
parent | 6acf19370e8adff79cd83b257d3f04aeaf2a59dd (diff) |
merge sources into single tree
Diffstat (limited to 'src/math/frexp.c')
-rw-r--r-- | src/math/frexp.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/math/frexp.c b/src/math/frexp.c new file mode 100644 index 00000000..70c87eb1 --- /dev/null +++ b/src/math/frexp.c @@ -0,0 +1,39 @@ +# define TGSOURCE "frexp.c" +#include <math.h> +#include "nonstd/tgmath.h" +#include "errno.h" + +/** extract mantissa and exponent **/ +TYPE TGFN(frexp)(TYPE value, int *exp) +{ + if (0) { + errno = ERANGE; /* The result cannot be represented */ + /* RETURN(CONSTANT(HUGE_VAL), A range error occurred); */ + return TGHUGE; + } + + /* RETURN(a value in range [1/2``,'' 1``)'', TODO: explain this); */ + /* RETURN(LITERAL(0), ARGUMENT(x) is LITERAL(0)); */ + (void)exp; + return value; +} + +/*** +break floating-point numbers into a normalized fraction and an integral power +of 2. + +The normalized fraction is a value in the range [1/2, 1) or 0. + +The integral exponent of 2 is stored in the TYPE(int) pointed to by +ARGUMENT(exp). + +Multiplying the normalized fraction by 2 to the power ARGUMENT(*exp). +***/ + +/* +IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) +LINK(m) +*/ +/* +STDC(1) +*/ |