From 250bb71e7e7c73163916baa0ab54e4414c331317 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Tue, 7 Feb 2012 17:26:49 -0800 Subject: [PATCH] Add isZero/isNonZero to avoid !!hash constructs. --- uint256.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/uint256.h b/uint256.h index 719c3355da..17de428736 100644 --- a/uint256.h +++ b/uint256.h @@ -33,6 +33,19 @@ protected: unsigned int pn[WIDTH]; public: + bool isZero() const + { + for (int i = 0; i < WIDTH; i++) + if (pn[i] != 0) + return false; + return true; + } + + bool isNonZero() const + { + return !isZero(); + } + bool operator!() const { for (int i = 0; i < WIDTH; i++) @@ -279,7 +292,7 @@ public: return false; return true; } - + friend inline bool operator!=(const base_uint& a, const base_uint& b) { return (!(a == b));