File tree Expand file tree Collapse file tree 4 files changed +88
-2
lines changed
Expand file tree Collapse file tree 4 files changed +88
-2
lines changed Original file line number Diff line number Diff line change 25532553@ cdecl scalbln (double long ) scalbn # double scalbln(double x, long exp);
25542554@ cdecl scalblnf (float long ) scalbnf # float scalblnf(float x, long exp);
25552555@ cdecl scalblnl (double long ) scalbn # long double scalblnl(long double x, long exp);
2556- @ cdecl - stub scalbn (double long ) # double scalbn(double x, int exp);
2557- @ cdecl - stub scalbnf (float long ) # float scalbnf(float x, int exp);
2556+ @ cdecl scalbn (double long ) # double scalbn(double x, int exp);
2557+ @ cdecl scalbnf (float long ) # float scalbnf(float x, int exp);
25582558@ cdecl scalbnl (double long ) scalbn # long double scalbnl(long double x, int exp);
25592559@ cdecl set_terminate (ptr )
25602560@ cdecl set_unexpected (ptr )
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ list(APPEND LIBCNTPR_MATH_SOURCE
1616 math /labs.c
1717 math /round.c
1818 math /roundf.c
19+ math /scalbn.c
20+ math /scalbnf.c
1921 math /sincos.c
2022)
2123
Original file line number Diff line number Diff line change 1+ /*
2+ * PROJECT: ReactOS CRT
3+ * LICENSE: MIT (https://spdx.org/licenses/MIT)
4+ * PURPOSE: Implementation of scalbn.
5+ * COPYRIGHT: Imported from musl libc
6+ * https://git.musl-libc.org/cgit/musl/tree/src/math/scalbn.c
7+ * blob: 182f561068fda7bc8321dfc7991df8b6d58e1b56
8+ * See https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT
9+ */
10+
11+ #include <math.h>
12+ #include <stdint.h>
13+
14+ double scalbn (double x , int n )
15+ {
16+ union {double f ; uint64_t i ;} u ;
17+ double_t y = x ;
18+
19+ if (n > 1023 ) {
20+ y *= 0x1p1023 ;
21+ n -= 1023 ;
22+ if (n > 1023 ) {
23+ y *= 0x1p1023 ;
24+ n -= 1023 ;
25+ if (n > 1023 )
26+ n = 1023 ;
27+ }
28+ } else if (n < -1022 ) {
29+ /* make sure final n < -53 to avoid double
30+ rounding in the subnormal range */
31+ y *= 0x1p-1022 * 0x1p53 ;
32+ n += 1022 - 53 ;
33+ if (n < -1022 ) {
34+ y *= 0x1p-1022 * 0x1p53 ;
35+ n += 1022 - 53 ;
36+ if (n < -1022 )
37+ n = -1022 ;
38+ }
39+ }
40+ u .i = (uint64_t )(0x3ff + n )<<52 ;
41+ x = y * u .f ;
42+ return x ;
43+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * PROJECT: ReactOS CRT
3+ * LICENSE: MIT (https://spdx.org/licenses/MIT)
4+ * PURPOSE: Implementation of scalbnf.
5+ * COPYRIGHT: Imported from musl libc
6+ * https://git.musl-libc.org/cgit/musl/tree/src/math/scalbnf.c
7+ * blob: a5ad208b69929f24336fae40e6af37101c99a72f
8+ * See https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT
9+ */
10+
11+ #include <math.h>
12+ #include <stdint.h>
13+
14+ float scalbnf (float x , int n )
15+ {
16+ union {float f ; uint32_t i ;} u ;
17+ float_t y = x ;
18+
19+ if (n > 127 ) {
20+ y *= 0x1p127f ;
21+ n -= 127 ;
22+ if (n > 127 ) {
23+ y *= 0x1p127f ;
24+ n -= 127 ;
25+ if (n > 127 )
26+ n = 127 ;
27+ }
28+ } else if (n < -126 ) {
29+ y *= 0x1p-126f * 0x1p24f ;
30+ n += 126 - 24 ;
31+ if (n < -126 ) {
32+ y *= 0x1p-126f * 0x1p24f ;
33+ n += 126 - 24 ;
34+ if (n < -126 )
35+ n = -126 ;
36+ }
37+ }
38+ u .i = (uint32_t )(0x7f + n )<<23 ;
39+ x = y * u .f ;
40+ return x ;
41+ }
You can’t perform that action at this time.
0 commit comments