From 049402e53bd0e0fb1f589366102b4e938dffa3b8 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Sun, 19 Nov 2017 13:13:21 +0100 Subject: Added the right-shift computation Signed-off-by: Olivier Gayot --- number.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'number.h') diff --git a/number.h b/number.h index 5043f1b..b1edbd6 100644 --- a/number.h +++ b/number.h @@ -62,6 +62,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. @@ -129,12 +137,27 @@ 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 _operands; }; -- cgit v1.2.3