Coverage Report

Created: 2026-08-14 06:19

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
46.0k
{
14
46.0k
  union {double f; uint64_t i;} u;
15
46.0k
  double_t y = x;
16
17
46.0k
  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
46.0k
  } else if (n < -1022) {
27
    /* make sure final n < -53 to avoid double
28
       rounding in the subnormal range */
29
10.8k
    y *= 0x1p-1022 * 0x1p53;
30
10.8k
    n += 1022 - 53;
31
10.8k
    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
10.8k
  }
38
46.0k
  u.i = (uint64_t)(0x3ff+n)<<52;
39
46.0k
  x = y * u.f;
40
46.0k
  return x;
41
46.0k
}