computing the significand of the given 64 bit is quite easy.
according to the wiki article using the IEEE 754, the significand is made up the first 53 bits (from bit 0 to bit 52). Now if you want to convert number having like 67 bits to your 64 bits value, it would be rounded by setting the trailing 64th bits of your value to 1, even if it was one before... because of the other 3 bits:
11110000 11110010 11111 becomes 11110000 11110011 after the rounding of the last byte;
therefore the there is no need to store the 53th bits because it has always a value a one. that's why you only store in 52 bits in the significand instead of 53.
now to compute it, you just need to target the bit range of the significand [bit(1) - bit(52)] -bit(0) is always 1- and use it .
int index_signf = 1; // starting at 1, not 0 int significand_length = 52; int byteArray[53]; // array containing the bits of the significand double significand_endValue = 0; for( ; index_signf <= significand_length ; index_signf ++) { significand_endValue += byteArray[index_signf] * (pow(2,-(index_signf))); } significand_endValue += 1;
Now you just have to fill byteArray accordlingly before computing it, using function like that:
int* getSignificandBits(int* array64bits){ //returned array int significandBitsArray[53]; // indexes++ int i_array64bits = 0; int i_significandBitsArray=1; //set the first bit = 1 significandBitsArray[0] = 1; // fill it for(i_significandBitsArray=1, i_array64bits = (63 - 1); i_array64bits >= (64 - 52); i_array64bits--, i_significandBitsArray ++) significandBitsArray[i_significandBitsArray] = array64bits[i_array64bits]; return significandBitsArray; }