summaryrefslogtreecommitdiff
path: root/number.h
diff options
context:
space:
mode:
authorOlivier Gayot <og@satcom1.com>2017-08-26 00:15:58 +0200
committerOlivier Gayot <og@satcom1.com>2017-11-19 14:00:12 +0100
commit671f3f8ca44382386daf63c70140742e61200c2e (patch)
tree4a99e06fc2ec3604db7348aab545fdb070866b8f /number.h
parent59962a745c0ca1e3237c8634005787eb1c8bbfde (diff)
Added a class "number" with comparison operators
Signed-off-by: Olivier Gayot <og@satcom1.com>
Diffstat (limited to 'number.h')
-rw-r--r--number.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/number.h b/number.h
new file mode 100644
index 0000000..c508a81
--- /dev/null
+++ b/number.h
@@ -0,0 +1,62 @@
+#pragma once
+
+#include <list>
+
+#include <cstdint>
+
+class number {
+public:
+ number() = default;
+
+ /**
+ * \brief Tells whether the number passed as parameter is strictly less
+ * than this number.
+ *
+ * \param n The number to compare with this number.
+ */
+ bool operator<(const number &n) const;
+
+ /**
+ * \brief Tells whether the number passed as parameter is strictly greater
+ * than this number.
+ *
+ * \param n The number to compare with this number.
+ */
+ bool operator>(const number &n) const;
+
+ /**
+ * \brief Tells whether the number passed as parameter is less than or
+ * equal to this number.
+ *
+ * \param n The number to compare with this number.
+ */
+ bool operator<=(const number &n) const;
+
+ /**
+ * \brief Tells whether the number passed as parameter is greater than or
+ * equal to this number.
+ *
+ * \param n The number to compare with this number.
+ */
+ bool operator>=(const number &n) const;
+
+ /**
+ * \brief Tells whether the number passed as parameter is equal to this
+ * number.
+ *
+ * \param n The number to compare with this number.
+ */
+ bool operator==(const number &n) const;
+
+ /**
+ * \brief Tells whether the number passed as parameter is not equal to this
+ * number.
+ *
+ * \param n The number to compare with this number.
+ */
+ bool operator!=(const number &n) const;
+
+private:
+ /* First item is the least significant. */
+ std::list<std::uint64_t> _operands;
+};