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

Function arithmetic_shift

include/half.hpp:605–612  ·  view source on GitHub ↗

Platform-independent arithmetic right shift. \param arg integer value in two's complement \param i shift amount (at most 31) \return \a arg right shifted for \a i bits with possible sign extension

Source from the content-addressed store, hash-verified

603 /// \param i shift amount (at most 31)
604 /// \return \a arg right shifted for \a i bits with possible sign extension
605 inline uint32 arithmetic_shift(uint32 arg, int i)
606 {
607 #if HALF_TWOS_COMPLEMENT_INT
608 return static_cast<int32>(arg) >> i;
609 #else
610 return static_cast<int32>(arg)/(static_cast<int32>(1)<<i) - ((arg>>(std::numeric_limits<uint32>::digits-1))&1);
611 #endif
612 }
613
614 /// \}
615 /// \name Error handling

Callers 2

sincosFunction · 0.85
atan2Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected