From 615b8a00aedb3363b4749f706d6df51846b743ac Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Sat, 18 Nov 2017 17:21:59 +0100 Subject: Allow conversion of number to 32 bits integer The method to_uint32() converts a number to a 32-bits-wide integer. The function throws if number cannot be represented using only a single 32-bits-wide integer. Signed-off-by: Olivier Gayot --- number.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'number.h') diff --git a/number.h b/number.h index 189011d..d93ed70 100644 --- a/number.h +++ b/number.h @@ -25,6 +25,14 @@ public: */ std::string to_dec_string() const; + /** + * \brief Return a 32-bits-wide integer that corresponds to this number. + * + * \throws std::out_of_range The number cannot be represented by a single + * 32-bits-wide integer. + */ + std::uint32_t to_uint32() const; + /** * \brief Return the result of the addition of a number and this number. * -- cgit v1.2.3