File: nextafter_fp32.cl

package info (click to toggle)
pocl 6.0-6
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 25,304 kB
  • sloc: lisp: 149,513; ansic: 103,778; cpp: 54,947; python: 1,513; sh: 949; ruby: 255; pascal: 226; tcl: 180; makefile: 173; java: 72; xml: 49
file content (23 lines) | stat: -rw-r--r-- 646 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

_CL_OVERLOADABLE vtype nextafter(vtype x, vtype y) {

  const itype sign_bit
   = (itype)1 << (sizeof(itype) * 8 - 1);
  const itype sign_bit_mask = as_itype(as_utype(sign_bit) - (utype)1);

  itype ix = as_itype(x);
  itype ax = ix & sign_bit_mask;
  itype mx = sign_bit - ix;
  mx = ix < (itype)0 ? mx : ix;
  itype iy = as_itype(y);
  itype ay = iy & sign_bit_mask;
  itype my = sign_bit - iy;
  my = iy < (itype)0 ? my : iy;
  itype t = mx + (mx < my ? 1 : -1);
  itype r = sign_bit - t;
  r = t < (itype)0 ? r : t;
  r = isnan(x) ? ix : r;
  r = isnan(y) ? iy : r;
  r = ((ax | ay) == (itype)0 | ix == iy) ? iy : r;
  return as_vtype(r);
}