@@ -120,7 +120,7 @@ uint8_t BigInt::byte_at(size_t n) const {
120120}
121121
122122int32_t BigInt::cmp_word (word other) const {
123- if (is_negative () ) {
123+ if (signum () < 0 ) {
124124 return -1 ; // other is positive ...
125125 }
126126
@@ -137,15 +137,15 @@ int32_t BigInt::cmp_word(word other) const {
137137*/
138138int32_t BigInt::cmp (const BigInt& other, bool check_signs) const {
139139 if (check_signs) {
140- if (other.is_positive () && this ->is_negative () ) {
140+ if (other.signum () >= 0 && this ->signum () < 0 ) {
141141 return -1 ;
142142 }
143143
144- if (other.is_negative () && this ->is_positive () ) {
144+ if (other.signum () < 0 && this ->signum () >= 0 ) {
145145 return 1 ;
146146 }
147147
148- if (other.is_negative () && this ->is_negative () ) {
148+ if (other.signum () < 0 && this ->signum () < 0 ) {
149149 return (-bigint_cmp (this ->_data (), this ->size (), other._data (), other.size ()));
150150 }
151151 }
@@ -162,15 +162,15 @@ bool BigInt::is_equal(const BigInt& other) const {
162162}
163163
164164bool BigInt::is_less_than (const BigInt& other) const {
165- if (this ->is_negative () && other.is_positive () ) {
165+ if (this ->signum () < 0 && other.signum () >= 0 ) {
166166 return true ;
167167 }
168168
169- if (this ->is_positive () && other.is_negative () ) {
169+ if (this ->signum () >= 0 && other.signum () < 0 ) {
170170 return false ;
171171 }
172172
173- if (other.is_negative () && this ->is_negative () ) {
173+ if (other.signum () < 0 && this ->signum () < 0 ) {
174174 return bigint_ct_is_lt (other._data (), other.size (), this ->_data (), this ->size ()).as_bool ();
175175 }
176176
@@ -265,7 +265,7 @@ uint32_t BigInt::get_substring(size_t offset, size_t length) const {
265265* Convert this number to a uint32_t, if possible
266266*/
267267uint32_t BigInt::to_u32bit () const {
268- if (is_negative () ) {
268+ if (signum () < 0 ) {
269269 throw Encoding_Error (" BigInt::to_u32bit: Number is negative" );
270270 }
271271 if (bits () > 32 ) {
@@ -327,7 +327,7 @@ BigInt BigInt::operator-() const {
327327}
328328
329329size_t BigInt::reduce_below (const BigInt& p, secure_vector<word>& ws) {
330- if (p.is_negative () || this ->is_negative () ) {
330+ if (p.signum () < 0 || this ->signum () < 0 ) {
331331 throw Invalid_Argument (" BigInt::reduce_below both values must be positive" );
332332 }
333333
@@ -359,7 +359,7 @@ size_t BigInt::reduce_below(const BigInt& p, secure_vector<word>& ws) {
359359}
360360
361361void BigInt::ct_reduce_below (const BigInt& mod, secure_vector<word>& ws, size_t bound) {
362- if (mod.is_negative () || this ->is_negative () ) {
362+ if (mod.signum () < 0 || this ->signum () < 0 ) {
363363 throw Invalid_Argument (" BigInt::ct_reduce_below both values must be positive" );
364364 }
365365
@@ -447,7 +447,7 @@ void BigInt::assign_from_bytes(std::span<const uint8_t> bytes) {
447447}
448448
449449void BigInt::ct_cond_add (bool predicate, const BigInt& value) {
450- if (this ->is_negative () || value.is_negative () ) {
450+ if (this ->signum () < 0 || value.signum () < 0 ) {
451451 throw Invalid_Argument (" BigInt::ct_cond_add requires both values to be positive" );
452452 }
453453 const size_t v_words = value.sig_words ();
0 commit comments