~rabbits/gyo

78cb6a5dd59a0106298ab1d88767ef97ae254f45 — d_m 1 year, 5 days ago 10b9bb9
comparisons for bc15 numbers
2 files changed, 15 insertions(+), 0 deletions(-)

M src/bcb.c
M src/bcb.h
M src/bcb.c => src/bcb.c +14 -0
@@ 226,6 226,20 @@ bc15carry(int next, int *digit, int *carry)
	}
}

bc3
bc15cmp(bc15 a, bc15 b)
{
	int i;
	for(i = 28; i >= 0; i -= 2) {
		/* altered repr: 0 (-) 1 (zero) 2 (+) */
		bc3 x = ((a >> i) + 1) & 0x3;
		bc3 y = ((b >> i) + 1) & 0x3;
		if (x != y)
			return x < y ? 3 : 1;
	}
	return 0;
}

// Unsigned(TODO: migrate to 11-00-01 encoding)

int

M src/bcb.h => src/bcb.h +1 -0
@@ 53,6 53,7 @@ bc15 bc15tnor(bc15 a);
bc15 bc15negate(bc15 a);
bc15 bc15add(bc15 a, bc15 b);
void bc15carry(int sum, int *digit, int *carry);
bc15 bc15cmp(bc15 a, bc15 b);

// Unsigned
int uc15int(uc15 t);