libzahl

big integer library
git clone git://git.suckless.org/libzahl
Log | Files | Refs | README | LICENSE

znot.c (419B)


      1 /* See LICENSE file for copyright and license details. */
      2 #include "internals.h"
      3 
      4 
      5 void
      6 znot(z_t a, z_t b)
      7 {
      8 	size_t bits;
      9 
     10 	if (unlikely(zzero(b))) {
     11 		SET_SIGNUM(a, 0);
     12 		return;
     13 	}
     14 
     15 	bits = zbits(b);
     16 	a->used = b->used;
     17 	SET_SIGNUM(a, -zsignum(b));
     18 
     19 	ZMEM_1OP(a->chars, b->chars, a->used, ~);
     20 	bits = BITS_IN_LAST_CHAR(bits);
     21 	if (bits)
     22 		a->chars[a->used - 1] &= ((zahl_char_t)1 << bits) - 1;
     23 
     24 	TRIM_AND_ZERO(a);
     25 }