MCPcopy Create free account
hub / github.com/numpy/numpy / npy_half_nextafter

Function npy_half_nextafter

numpy/core/src/npymath/halffloat.cpp:104–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102}
103
104npy_half npy_half_nextafter(npy_half x, npy_half y)
105{
106 npy_half ret;
107
108 if (npy_half_isnan(x) || npy_half_isnan(y)) {
109 ret = NPY_HALF_NAN;
110 } else if (npy_half_eq_nonan(x, y)) {
111 ret = x;
112 } else if (npy_half_iszero(x)) {
113 ret = (y&0x8000u) + 1; /* Smallest subnormal half */
114 } else if (!(x&0x8000u)) { /* x > 0 */
115 if ((npy_int16)x > (npy_int16)y) { /* x > y */
116 ret = x-1;
117 } else {
118 ret = x+1;
119 }
120 } else {
121 if (!(y&0x8000u) || (x&0x7fffu) > (y&0x7fffu)) { /* x < y */
122 ret = x-1;
123 } else {
124 ret = x+1;
125 }
126 }
127#if NPY_HALF_GENERATE_OVERFLOW
128 if (npy_half_isinf(ret) && npy_half_isfinite(x)) {
129 npy_set_floatstatus_overflow();
130 }
131#endif
132
133 return ret;
134}
135
136int npy_half_eq_nonan(npy_half h1, npy_half h2)
137{

Callers

nothing calls this directly

Calls 6

npy_half_isnanFunction · 0.85
npy_half_eq_nonanFunction · 0.85
npy_half_iszeroFunction · 0.85
npy_half_isinfFunction · 0.85
npy_half_isfiniteFunction · 0.85

Tested by

no test coverage detected