64-bit division. \param x upper 32 bit of dividend \param y divisor \param s variable to store sticky bit for rounding \return (\a x << 32) / \a y
| 1378 | /// \param s variable to store sticky bit for rounding |
| 1379 | /// \return (\a x << 32) / \a y |
| 1380 | inline uint32 divide64(uint32 x, uint32 y, int &s) |
| 1381 | { |
| 1382 | #if HALF_ENABLE_CPP11_LONG_LONG |
| 1383 | unsigned long long xx = static_cast<unsigned long long>(x) << 32; |
| 1384 | return s = (xx%y!=0), static_cast<uint32>(xx/y); |
| 1385 | #else |
| 1386 | y >>= 1; |
| 1387 | uint32 rem = x, div = 0; |
| 1388 | for(unsigned int i=0; i<32; ++i) |
| 1389 | { |
| 1390 | div <<= 1; |
| 1391 | if(rem >= y) |
| 1392 | { |
| 1393 | rem -= y; |
| 1394 | div |= 1; |
| 1395 | } |
| 1396 | rem <<= 1; |
| 1397 | } |
| 1398 | return s = rem > 1, div; |
| 1399 | #endif |
| 1400 | } |
| 1401 | |
| 1402 | /// Half precision positive modulus. |
| 1403 | /// \tparam Q `true` to compute full quotient, `false` else |
no outgoing calls
no test coverage detected