I'm trying to create a program to add two IEEE 754 floating point numbers, I'm pretty far into the program but I've come to a halt in the bit shift section of the algorithm.
I have created a tmp variable to copy the mantissa(0's and 1's inside the char array to be shifted to the right). Then I copy the tmp variable into the previous variable in the spots needed... Any help or suggestions will be appreciated... here is my code that needs reworking.
if( e1 > e2 ){ // If exponent 1 is greater than exponent 2 shift exponent 2
k = e1 - e2; // k = size of shift
for(i = 11; i < 40; i++) // for loop for original array
for(j = 1; j < 30; j++) // for loop for tmp array
tmp_bit_string[j] = bit_string2[i]; // copy original into tmp
*tmp_bit_string >>= k; //shift tmp
for(i = 11; i < 40; i++) //second loop to copy tmp back into original
for(j = 1; j < 30; j++)
tmp_bit_string[j] = bit_string2[i];
}
if( e2 > e1 ){ //same thing but opposite of previous loop
k = e2 - e1;
for(i = 11; i < 40; i++)
for(j = 1; j < 30; j++)
tmp_bit_string[j] = bit_string[i];
*tmp_bit_string >>= k;
for(i = 11; i < 40; i++)
for(j = 1; j < 30; j++)
tmp_bit_string[j] = bit_string[i];
}