1/*
2 * Copyright (c) 2005-2020 Rich Felker, et al.
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Please see https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT
7 * for all contributors to musl.
8 */
9#include <math.h>
10#include <stdint.h>
11
12float scalbnf(float x, int n)
13{
14	union {float f; uint32_t i;} u;
15	float_t y = x;
16
17	if (n > 127) {
18		y *= 0x1p127f;
19		n -= 127;
20		if (n > 127) {
21			y *= 0x1p127f;
22			n -= 127;
23			if (n > 127)
24				n = 127;
25		}
26	} else if (n < -126) {
27		y *= 0x1p-126f * 0x1p24f;
28		n += 126 - 24;
29		if (n < -126) {
30			y *= 0x1p-126f * 0x1p24f;
31			n += 126 - 24;
32			if (n < -126)
33				n = -126;
34		}
35	}
36	u.i = (uint32_t)(0x7f+n)<<23;
37	x = y * u.f;
38	return x;
39}
40
41__strong_reference(scalbnf, ldexpf);
42