diff options
author | 2009-07-25 11:38:09 +0000 | |
---|---|---|
committer | 2009-07-25 11:38:09 +0000 | |
commit | ed1ba055d0dc2156a4291f835c44e14dc408fa36 (patch) | |
tree | 00377d83e0612176e2aaaac378f947164ff76fd2 /lib/libm/noieee_src | |
parent | Stop using rbus to set up the socket BAR if it has been left unitialized (diff) | |
download | wireguard-openbsd-ed1ba055d0dc2156a4291f835c44e14dc408fa36.tar.xz wireguard-openbsd-ed1ba055d0dc2156a4291f835c44e14dc408fa36.zip |
int is big enough to fully represent exponents of all supported fp
formats. which even for 80-bit & 128-bit long doubles is only 15
bits. therefore, scalbln, scalblnf, scalblnl are essentially the
same as scalbn, scalbnf, scalbnl with bounds checking so that
LONG_MIN..INT_MIN, and INT_MAX..LONG_MAX ranges properly raise
exceptions & yield correct values. looks good to millert@
Diffstat (limited to 'lib/libm/noieee_src')
-rw-r--r-- | lib/libm/noieee_src/n_scalbln.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/libm/noieee_src/n_scalbln.c b/lib/libm/noieee_src/n_scalbln.c new file mode 100644 index 00000000000..c1fd86a4682 --- /dev/null +++ b/lib/libm/noieee_src/n_scalbln.c @@ -0,0 +1,31 @@ +/* $OpenBSD: n_scalbln.c,v 1.1 2009/07/25 11:38:10 martynas Exp $ */ + +/* + * Written by Martynas Venckus. Public domain + */ + +#include <limits.h> +#include <math.h> + +double +scalbln(double x, long n) +{ + if (n < INT_MIN) + return scalbn(x, INT_MIN); + else if (n > INT_MAX) + return scalbn(x, INT_MAX); + else + return scalbn(x, (int)n); +} + +long double +scalblnl(long double x, long n) +{ + if (n < INT_MIN) + return scalbnl(x, INT_MIN); + else if (n > INT_MAX) + return scalbnl(x, INT_MAX); + else + return scalbnl(x, (int)n); +} + |