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
| 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 |