Coverage Report

Created: 2026-03-16 06:17

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/moddable/xs/tools/fdlibm/s_scalbn.c
Line
Count
Source
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
10
#include "math_private.h"
11
12
double s_scalbn(double x, int n)
13
294k
{
14
294k
  union {double f; uint64_t i;} u;
15
294k
  double_t y = x;
16
17
294k
  if (n > 1023) {
18
0
    y *= 0x1p1023;
19
0
    n -= 1023;
20
0
    if (n > 1023) {
21
0
      y *= 0x1p1023;
22
0
      n -= 1023;
23
0
      if (n > 1023)
24
0
        n = 1023;
25
0
    }
26
294k
  } else if (n < -1022) {
27
    /* make sure final n < -53 to avoid double
28
       rounding in the subnormal range */
29
5.36k
    y *= 0x1p-1022 * 0x1p53;
30
5.36k
    n += 1022 - 53;
31
5.36k
    if (n < -1022) {
32
0
      y *= 0x1p-1022 * 0x1p53;
33
0
      n += 1022 - 53;
34
0
      if (n < -1022)
35
0
        n = -1022;
36
0
    }
37
5.36k
  }
38
294k
  u.i = (uint64_t)(0x3ff+n)<<52;
39
294k
  x = y * u.f;
40
294k
  return x;
41
294k
}