MCPcopy Create free account
hub / github.com/apache/singa / divide64

Function divide64

include/half.hpp:1380–1400  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

Callers 8

hyperbolic_argsFunction · 0.85
exp2_postFunction · 0.85
log2_postFunction · 0.85
tangent_postFunction · 0.85
operator/Method · 0.85
expm1Function · 0.85
cbrtFunction · 0.85
atanhFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected