Remainder implementation. \param x first operand \param y second operand \return Half-precision division remainder stored in single-precision
| 1271 | /// \param y second operand |
| 1272 | /// \return Half-precision division remainder stored in single-precision |
| 1273 | static expr remainder(float x, float y) |
| 1274 | { |
| 1275 | #if HALF_ENABLE_CPP11_CMATH |
| 1276 | return expr(std::remainder(x, y)); |
| 1277 | #else |
| 1278 | if(builtin_isnan(x) || builtin_isnan(y)) |
| 1279 | return expr(std::numeric_limits<float>::quiet_NaN()); |
| 1280 | float ax = std::fabs(x), ay = std::fabs(y); |
| 1281 | if(ax >= 65536.0f || ay < std::ldexp(1.0f, -24)) |
| 1282 | return expr(std::numeric_limits<float>::quiet_NaN()); |
| 1283 | if(ay >= 65536.0f) |
| 1284 | return expr(x); |
| 1285 | if(ax == ay) |
| 1286 | return expr(builtin_signbit(x) ? -0.0f : 0.0f); |
| 1287 | ax = std::fmod(ax, ay+ay); |
| 1288 | float y2 = 0.5f * ay; |
| 1289 | if(ax > y2) |
| 1290 | { |
| 1291 | ax -= ay; |
| 1292 | if(ax >= y2) |
| 1293 | ax -= ay; |
| 1294 | } |
| 1295 | return expr(builtin_signbit(x) ? -ax : ax); |
| 1296 | #endif |
| 1297 | } |
| 1298 | |
| 1299 | /// Remainder implementation. |
| 1300 | /// \param x first operand |
nothing calls this directly
no test coverage detected