looking for inversed double values

42 views Asked by At

I am looking for inverse double values

if( temp1.p[j] == -temp2.p[j] ) {
    cout << "Inverse Value \n";
}

Problem I have is that when I multiple the following value they are not always completely exact for instance the last 3 digits.

temp2.p[j] =   0.91217251125729792
-temp2.p[j] = -0.91217251124879162 

Now I suspect it has something to do with the precision of doubles and the operation of sign bit but my question is what is the quickest solution?

I thought it would be easy to choose a precision of a double but this seems to only be the case when printing. So do I need to convert the values to strings in order to compare or is there a quicker method?

0

There are 0 answers