1. Bignum math: right shift

Thought that maybe my FPN math for double's with large exponents was giving wrong result because of insufficient integer size so I decided to write a all in one bignum math file and then try with that instead, either way I would need to for the compiler I'm writing.
I got the left shift working just fine, I then did a copy & paste
and flipped the direction of logic, unfortunately for some reason it's not working and I can't spot the problem myself, hoping someone here can.
Code:
Code:
```int shr__bi( bint_t *num, bint_t *val ) {
int ret = bint_validate2( num, val );
bint_t tmp = {0};
bibit_t n, v, e;
if ( ret != EXIT_SUCCESS ) return ret;
ret = bitemp( &tmp, &(num->stop.b), 1 );
if ( ret != EXIT_SUCCESS ) return ret;
if ( gte__bi( val, &tmp ) ) {
memset( num->zero.seg, 0, num->size );
return EXIT_SUCCESS;
}
else if ( !(*(val->zero.seg)) ) return EXIT_SUCCESS;
v = add_bibit( num->zero, *(val->zero.seg) );
n = num->zero;
e = dec_bibit(num->stop);
printf("e.b = %lu, v.b = %lu, n.b = %lu\n", e.b, v.b, n.b );
printf("e.bit = %016lX, v.bit = %016lu, n.bit = %016lu\n",
e.bit, v.bit, n.bit );
printf("num %016lX\n", *(num->zero.seg) );
while ( v.b < e.b ) {
n = inc_bibit(n);
v = inc_bibit(v);
if ( *(v.seg) & v.bit )
*(n.seg) |= n.bit;
else if ( *(n.seg) & n.bit )
*(n.seg) ^= n.bit;
}
printf("num %016lX\n", *(num->zero.seg) );
while ( n.bit << 1 ) {
n = inc_bibit(n);
if ( *(n.seg) & n.bit )
*(n.seg) ^= n.bit;
}
printf("num %016lX\n", *(num->zero.seg) );
if ( n.i < e.i ) {
n.i = e.i - n.i;
memset( ++(n.seg), 0, n.i * sizeof(biseg_t) );
}
return EXIT_SUCCESS;
}```
Output:
Code:
```gcc -Wall -o "bimath" "bimath.c" && "./bimath"
_num = 0000000000000000, num = 0000000000000000, op = '=='
_num = 0000000000000001, num = 0000000000000001, op = '!='
_num = 0000000000000001, num = 0000000000000001, op = '>'
_num = 0000000000000001, num = 0000000000000001, op = '>='
_num = 0000000000000000, num = 0000000000000000, op = '<'
_num = 0000000000000000, num = 0000000000000000, op = '<='
_num = 0000000000000100, num = 0000000000000100, op = '<<'
e.b = 63, v.b = 2, n.b = 0
e.bit = 8000000000000000, v.bit = 0000000000000004, n.bit = 0000000000000001
num 0000000000000040
num 0000000000000000
num 0000000000000000
_num = 0000000000000000, num = 0000000000000010, op = '>>'
_num = 0000000000000042, num = 0000000000000042, op = '+'
Compilation finished successfully.```
Edit: Where _num is mentioned num is correct, _num is result of my functions

2. Turned out the problem was with add_bibit(), I forgot to filter out the scenario where bits % sizeof(biseg_t) AND bits < bitsof(biseg_t) were true.