Decimal Number

 

please what piece of code can i use to reduce this number 79.77739518770201 to four places of decimal, that is it will be 79.7773

I don't know whether MathCell can do it.

 
  1. You can do it mathematically on your own: (int(79.77739518770201*10000.0 + 0.5))/10000.0;
  2. You can use MQ-functions (seach with F1 for MathRound or MathFloor): MathFloor(79.77739518770201*10000.0 + 0.5)/10000.0 or MathRound(79.77739518770201*10000.0 )/10000.0
  3. Or you want see as a text number: DoubleToString( 79.77739518770201, 4)

(Not tested!)

 
pekele4u: reduce this number 79.77739518770201 to four places of decimal, that is it will be 79.7773
int OnInit(){
   double n=79.77739518770201; Print( MathNearest(n, 0.0001) ); // 79.7774
          MT4:NormalizeDouble - General - MQL5 programming forum
          How to Normalize - Expert Advisors and Automated Trading - MQL5 programming forum