1. ## Bugs in quickly made code

Would've stuck this in a previous thread but I think my previous post there will be ignored for sure if I do that so separate thread it is, made some bitwise math for my bignum code but results came out partially incorrect (I'm just gonna assuming the rest was just a coincidence)

I have to get ready for work so figured I'd post the code here with the output and see if I strike lucky by the time I get a chance to return to this:
Code:
```int _alu_upto( alu_t *alu, int num, int val, alu_bit_t *pos )
{
int ret = _alu_check2( alu, num, val );
alu_reg_t *N, *V;
alu_bit_t n, v;
size_t ndiff, vdiff;

if ( ret != 0 )
{
alu_error( ret );
return ret;
}

if ( !pos )
{
alu_error( ret );
return ret;
}

N = alu->regv + num;
V = alu->regv + val;

ndiff = (N->upto.b - N->init.b);
vdiff = (V->upto.b - V->init.b);

*pos = alu_bit_set_bit(
N->part,
N->init.b + ((ndiff < vdiff) ? ndiff : vdiff)
);

return 0;
}

int _alu_and( alu_t *alu, int num, int val )
{
alu_bit_t n, v, e = {0};
int ret = _alu_upto( alu, num, val, &e );
alu_reg_t *N, *V;

if ( ret != 0 )
{
alu_error( ret );
return ret;
}

N = alu->regv + num;
V = alu->regv + val;

for
(
n = N->init, v = V->init;
n.b < e.b;
n = alu_bit_inc( n ), v = alu_bit_inc( v )
)
{
if ( (*(n.S) & n.B) && !(*(v.S) & v.B) )
*(n.S) ^= n.B;
}

while ( n.b < N->upto.b )
{
*(n.S) &= ~(n.B);
n = alu_bit_inc(n);
}

return 0;
}

int _alu__or( alu_t *alu, int num, int val )
{
alu_bit_t n, v, e = {0};
int ret = _alu_upto( alu, num, val, &e );
alu_reg_t *N, *V;

if ( ret != 0 )
{
alu_error( ret );
return ret;
}

N = alu->regv + num;
V = alu->regv + val;

for
(
n = N->init, v = V->init;
n.b < e.b;
n = alu_bit_inc( n ), v = alu_bit_inc( v )
)
{
*(n.S) |= (*(v.S) & v.B) ? n.B : ALU_SEG_C(0);
}

return 0;
}

int _alu_xor( alu_t *alu, int num, int val )
{
alu_bit_t n, v, e = {0};
int ret = _alu_upto( alu, num, val, &e );
alu_reg_t *N, *V;

if ( ret != 0 )
{
alu_error( ret );
return ret;
}

N = alu->regv + num;
V = alu->regv + val;

for
(
n = N->init, v = V->init;
n.b < e.b;
n = alu_bit_inc( n ), v = alu_bit_inc( v )
)
{
*(n.S) ^= (*(v.S) & v.B) ? n.B : ALU_SEG_C(0);
}

return 0;
}```
Code:
```...
./alu.AppImage
test.c:224: main() 'Initiating ALU to 0...'
test.c:227: main() 'Pre-allocating 16 ALU registers...'
test.c:230: main() 'Requesting register for number to modify...'
test.c:239: main() 'Requesting register for value to modify by...'
test.c:248: main() 'Comparing values...'
test.c:56: compare() Expected 1, Got 1
test.c:56: compare() Expected 0, Got 0
test.c:56: compare() Expected -1, Got -1
test.c:254: main() 'Shifting values...'
test.c:95: modify() num = 6, val = 7, N = 00000000DEADC0DE, V = 0000000000000002, _num = 00000000DEADC0DE, _val = 0000000000000002
test.c:199: modify() 00000000DEADC0DE << 0000000000000002, Expected 000000037AB70378, Got 000000037AB70378, op = '<'
test.c:95: modify() num = 6, val = 7, N = 00000000DEADC0DE, V = 0000000000000002, _num = 00000000DEADC0DE, _val = 0000000000000002
test.c:199: modify() 00000000DEADC0DE >> 0000000000000002, Expected 0000000037AB7037, Got 0000000037AB7037, op = '>'
test.c:258: main() 'Rotating values...'
test.c:95: modify() num = 6, val = 7, N = 00000000DEADC0DE, V = 0000000000000002, _num = 00000000DEADC0DE, _val = 0000000000000002
test.c:199: modify() 00000000DEADC0DE <<< 0000000000000002, Expected 000000037AB70378, Got 000000037AB70378, op = 'l'
test.c:95: modify() num = 6, val = 7, N = 00000000DEADC0DE, V = 0000000000000002, _num = 00000000DEADC0DE, _val = 0000000000000002
test.c:199: modify() 00000000DEADC0DE >>> 0000000000000002, Expected 8000000037AB7037, Got 8000000037AB7037, op = 'r'
test.c:262: main() 'Bitwising values...'
test.c:95: modify() num = 6, val = 7, N = 00000000DEADC0DE, V = 0000000000C0FFEE, _num = 00000000DEADC0DE, _val = 0000000000C0FFEE
test.c:199: modify() 00000000DEADC0DE & 0000000000C0FFEE, Expected 000000000080C0CE, Got 00000000DF6EC0CC, op = '&'
alu_main.c:86: alu_pri_reg() reg = 6, REG->part = 0x5616e5aa02d0
alu_main.c:88: alu_pri_reg() REG->upto.b = 64, REG->last.b = 63, REG->init.b = 0
alu_main.c:93: alu_pri_reg() REG->upto.s = 1, REG->last.s = 0, REG->init.s = 0
alu_main.c:98: alu_pri_reg() REG->upto.S = 0x5616e5aa02d8, REG->last.S = 0x5616e5aa02d0, REG->init.S = 0x5616e5aa02d0
0000000000000000000000000000000011011111011011101100000011001100
alu_main.c:86: alu_pri_reg() reg = 6, REG->part = 0x5616e5aa02d0
alu_main.c:88: alu_pri_reg() REG->upto.b = 64, REG->last.b = 63, REG->init.b = 0
alu_main.c:93: alu_pri_reg() REG->upto.s = 1, REG->last.s = 0, REG->init.s = 0
alu_main.c:98: alu_pri_reg() REG->upto.S = 0x5616e5aa02d8, REG->last.S = 0x5616e5aa02d0, REG->init.S = 0x5616e5aa02d0
0000000000000000000000000000000000000000100000001100000011001110
test.c:95: modify() num = 6, val = 7, N = 00000000DEADC0DE, V = 0000000000C0FFEE, _num = 00000000DEADC0DE, _val = 0000000000C0FFEE
test.c:199: modify() 00000000DEADC0DE | 0000000000C0FFEE, Expected 00000000DEEDFFFE, Got 00000000DDECC0F0, op = '|'
alu_main.c:86: alu_pri_reg() reg = 6, REG->part = 0x5616e5aa02d0
alu_main.c:88: alu_pri_reg() REG->upto.b = 64, REG->last.b = 63, REG->init.b = 0
alu_main.c:93: alu_pri_reg() REG->upto.s = 1, REG->last.s = 0, REG->init.s = 0
alu_main.c:98: alu_pri_reg() REG->upto.S = 0x5616e5aa02d8, REG->last.S = 0x5616e5aa02d0, REG->init.S = 0x5616e5aa02d0
0000000000000000000000000000000011011101111011001100000011110000
alu_main.c:86: alu_pri_reg() reg = 6, REG->part = 0x5616e5aa02d0
alu_main.c:88: alu_pri_reg() REG->upto.b = 64, REG->last.b = 63, REG->init.b = 0
alu_main.c:93: alu_pri_reg() REG->upto.s = 1, REG->last.s = 0, REG->init.s = 0
alu_main.c:98: alu_pri_reg() REG->upto.S = 0x5616e5aa02d8, REG->last.S = 0x5616e5aa02d0, REG->init.S = 0x5616e5aa02d0
0000000000000000000000000000000011011110111011011111111111111110
test.c:95: modify() num = 6, val = 7, N = 00000000DEADC0DE, V = 0000000000C0FFEE, _num = 00000000DEADC0DE, _val = 0000000000C0FFEE
test.c:199: modify() 00000000DEADC0DE ^ 0000000000C0FFEE, Expected 00000000DE6D3F30, Got 00000000DDECC0F0, op = '^'
alu_main.c:86: alu_pri_reg() reg = 6, REG->part = 0x5616e5aa02d0
alu_main.c:88: alu_pri_reg() REG->upto.b = 64, REG->last.b = 63, REG->init.b = 0
alu_main.c:93: alu_pri_reg() REG->upto.s = 1, REG->last.s = 0, REG->init.s = 0
alu_main.c:98: alu_pri_reg() REG->upto.S = 0x5616e5aa02d8, REG->last.S = 0x5616e5aa02d0, REG->init.S = 0x5616e5aa02d0
0000000000000000000000000000000011011101111011001100000011110000
alu_main.c:86: alu_pri_reg() reg = 6, REG->part = 0x5616e5aa02d0
alu_main.c:88: alu_pri_reg() REG->upto.b = 64, REG->last.b = 63, REG->init.b = 0
alu_main.c:93: alu_pri_reg() REG->upto.s = 1, REG->last.s = 0, REG->init.s = 0
alu_main.c:98: alu_pri_reg() REG->upto.S = 0x5616e5aa02d8, REG->last.S = 0x5616e5aa02d0, REG->init.S = 0x5616e5aa02d0
0000000000000000000000000000000011011110011011010011111100110000
test.c:95: modify() num = 6, val = 7, N = 00000000DEADC0DE, V = 0000000000000002, _num = 00000000DEADC0DE, _val = 0000000000000002
test.c:95: modify() num = 6, val = 7, N = 00000000DEADC0DE, V = 0000000000000002, _num = 00000000DEADC0DE, _val = 0000000000000002
test.c:95: modify() num = 6, val = 7, N = 00000000DEADC0DE, V = 0000000000000000, _num = 00000000DEADC0DE, _val = 0000000000000000
test.c:273: main() 'Subtracting values...'
test.c:95: modify() num = 6, val = 7, N = 00000000DEADC0DE, V = 0000000000000002, _num = 00000000DEADC0DE, _val = 0000000000000002
test.c:95: modify() num = 6, val = 7, N = 00000000DEADC0DE, V = 0000000000000002, _num = 00000000DEADC0DE, _val = 0000000000000002
test.c:95: modify() num = 6, val = 7, N = 00000000DEADC0DE, V = 0000000000000000, _num = 00000000DEADC0DE, _val = 0000000000000000
test.c:278: main() 'Multiplying values...'
test.c:95: modify() num = 6, val = 7, N = 00000000DEADC0DE, V = 0000000000000002, _num = 00000000DEADC0DE, _val = 0000000000000002
test.c:199: modify() 00000000DEADC0DE * 0000000000000002, Expected 00000001BD5B81BC, Got 00000001BD5B81BC, op = '*'
test.c:95: modify() num = 6, val = 7, N = 00000000DEADC0DE, V = 0000000000000000, _num = 00000000DEADC0DE, _val = 0000000000000000
test.c:199: modify() 00000000DEADC0DE * 0000000000000000, Expected 0000000000000000, Got 0000000000000000, op = '*'
test.c:282: main() 'Dividing values...'
test.c:95: modify() num = 6, val = 7, N = 00000000DEADC0DE, V = 0000000000000002, _num = 00000000DEADC0DE, _val = 0000000000000002
test.c:199: modify() 00000000DEADC0DE / 0000000000000002, Expected 000000006F56E06F, Got 000000006F56E06F, op = '/'
test.c:95: modify() num = 6, val = 7, N = 00000000DEADC0DE, V = 0000000000000000, _num = 00000000DEADC0DE, _val = 0000000000000000
test.c:199: modify() 00000000DEADC0DE / 0000000000000000, Expected 0000000000000000, Got 0000000000000000, op = '/'
test.c:95: modify() num = 6, val = 7, N = 00000000DEADC0DE, V = 0000000000000002, _num = 00000000DEADC0DE, _val = 0000000000000002
test.c:199: modify() 00000000DEADC0DE % 0000000000000002, Expected 0000000000000000, Got 0000000000000000, op = '%'
test.c:95: modify() num = 6, val = 7, N = 00000000DEADC0DE, V = 0000000000000000, _num = 00000000DEADC0DE, _val = 0000000000000000