| 63 | } |
| 64 | |
| 65 | npy_half npy_half_spacing(npy_half h) |
| 66 | { |
| 67 | npy_half ret; |
| 68 | npy_uint16 h_exp = h&0x7c00u; |
| 69 | npy_uint16 h_sig = h&0x03ffu; |
| 70 | if (h_exp == 0x7c00u) { |
| 71 | #if NPY_HALF_GENERATE_INVALID |
| 72 | npy_set_floatstatus_invalid(); |
| 73 | #endif |
| 74 | ret = NPY_HALF_NAN; |
| 75 | } else if (h == 0x7bffu) { |
| 76 | #if NPY_HALF_GENERATE_OVERFLOW |
| 77 | npy_set_floatstatus_overflow(); |
| 78 | #endif |
| 79 | ret = NPY_HALF_PINF; |
| 80 | } else if ((h&0x8000u) && h_sig == 0) { /* Negative boundary case */ |
| 81 | if (h_exp > 0x2c00u) { /* If result is normalized */ |
| 82 | ret = h_exp - 0x2c00u; |
| 83 | } else if(h_exp > 0x0400u) { /* The result is a subnormal, but not the smallest */ |
| 84 | ret = 1 << ((h_exp >> 10) - 2); |
| 85 | } else { |
| 86 | ret = 0x0001u; /* Smallest subnormal half */ |
| 87 | } |
| 88 | } else if (h_exp > 0x2800u) { /* If result is still normalized */ |
| 89 | ret = h_exp - 0x2800u; |
| 90 | } else if (h_exp > 0x0400u) { /* The result is a subnormal, but not the smallest */ |
| 91 | ret = 1 << ((h_exp >> 10) - 1); |
| 92 | } else { |
| 93 | ret = 0x0001u; |
| 94 | } |
| 95 | |
| 96 | return ret; |
| 97 | } |
| 98 | |
| 99 | npy_half npy_half_copysign(npy_half x, npy_half y) |
| 100 | { |
nothing calls this directly
no test coverage detected