summaryrefslogtreecommitdiff
path: root/sysdeps/ieee754/ldbl-128ibm/s_isinf_nsl.c
blob: 54e72c9166b8e2d9355a91b0f11b106e26a2cbf1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
 * __isinf_nsl(x) returns != 0 if x is ±inf, else 0;
 * no branching!
 * slightly dodgy in relying on signed shift right copying sign bit
 */

#include <math.h>
#include <math_private.h>

int
__isinf_nsl (long double x)
{
  double xhi;
  int64_t hx, mask;

  xhi = ldbl_high (x);
  EXTRACT_WORDS64 (hx, xhi);

  mask = (hx & 0x7fffffffffffffffLL) ^ 0x7ff0000000000000LL;
  mask |= -mask;
  mask >>= 63;
  return ~mask;
}