Platform-independent sign mask. \param arg integer value in two's complement \retval -1 if \a arg negative \retval 0 if \a arg positive
| 589 | /// \retval -1 if \a arg negative |
| 590 | /// \retval 0 if \a arg positive |
| 591 | inline uint32 sign_mask(uint32 arg) |
| 592 | { |
| 593 | static const int N = std::numeric_limits<uint32>::digits - 1; |
| 594 | #if HALF_TWOS_COMPLEMENT_INT |
| 595 | return static_cast<int32>(arg) >> N; |
| 596 | #else |
| 597 | return -((arg>>N)&1); |
| 598 | #endif |
| 599 | } |
| 600 | |
| 601 | /// Platform-independent arithmetic right shift. |
| 602 | /// \param arg integer value in two's complement |