Error Code #1, how to avoid modify when the value is same.

 
if (OrderTakeProfit()!= tp || OrderStopLoss() != 0){ 
   if (OrderModify(OrderTicket(),OrderOpenPrice(),sl,tp,0,clrNONE)) 
     Print("Modified successfully");
     else Print("Error in OrderModify. Error code=",GetLastError());
}

I am trying to stop EA to modify the value when it has already modified. but the journal show many error code #1. I suppose the value is slightly different in the many decimal behind. Anyone knows where I can find solution to this problem? Thank you very much. 

 
if(MathAbs(OrderTakeProfit()-tp)>Point || MathAbs(OrderStopLoss()-sl1>Point)){
   if (OrderModify(OrderTicket(),OrderOpenPrice(),sl1,tp,0,clrNONE)) 
   Print("Modified successfully");
   else Print("Error in OrderModify. Error code=",GetLastError());
   }

after research some info in this forum. I tried to modify my code to this one... it seem to be helpful. no more error code #1.

But not very sure if this is correct. Hope to hear your advice. 

 
double point = SymbolInfoDouble(OrderSymbol(),SYMBOL_POINT);
bool stopLossChanged = (MathAbs(OrderStopLoss() - sl) >= point);
bool takeProfitChanged = (MathAbs(OrderTakeProfit() - tp) >= point);

if (stopLossChanged || takeProfitChanged){ 
   if (OrderModify(OrderTicket(),OrderOpenPrice(),sl,tp,0,clrNONE)) 
     Print("Modified successfully");
     else Print("Error in OrderModify. Error code=",GetLastError());
}
 
amrali:

Hi Amrali, Thanks for replying. May I know what is the benefit of writing it in this way??

 
Tan Chee Ho:

Hi Amrali, Thanks for replying. May I know what is the benefit of writing it in this way??

Because floating point roundoff errors make exact comparisons with == to fail. 
 
amrali:
Because floating point roundoff errors make exact comparisons with == to fail. 

thanks