diff options
author | Olivier Gayot <og@satcom1.com> | 2017-11-19 13:13:21 +0100 |
---|---|---|
committer | Olivier Gayot <og@satcom1.com> | 2017-11-25 18:10:56 +0100 |
commit | 049402e53bd0e0fb1f589366102b4e938dffa3b8 (patch) | |
tree | 46d9e2bb17c97dc82dadd74ddf4391c676a5496d /number.h | |
parent | ef6b1c0dd80a7b37161557aef49d01724f7f7531 (diff) |
Added the right-shift computation
Signed-off-by: Olivier Gayot <og@satcom1.com>
Diffstat (limited to 'number.h')
-rw-r--r-- | number.h | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -63,6 +63,14 @@ public: number operator<<(std::uint32_t n) const; /** + * \brief Return a number equals to this number where n bits have been + * shifted to the right. + * + * \param n Number of bits to shift. + */ + number operator>>(std::uint32_t) const; + + /** * \brief Tell whether the number passed as parameter is strictly less than * this number. * @@ -130,11 +138,26 @@ public: number &operator<<=(std::uint32_t); /** + * \brief Shift the number n bits to the right. + * + * \param n Number of bits to shift. + */ + number &operator>>=(std::uint32_t); + + /** * \brief Increment this number. */ number &operator++(); private: + /** + * \brief Remove unused leading 0 operands. + * + * Call this method after shrinking the number so that leading 0 operands + * are removed. + */ + void shrink_to_fit(); + /* First item is the least significant. */ std::list<std::uint32_t> _operands; }; |