# why not calculate correct ??

137

hi guys  i try to do a simply script

```//+------------------------------------------------------------------+
//|                                                  CalicettoPS.mq4 |
//|                        Copyright 2015, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
//---

//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---

}
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
//---
Comment (Close[6]-Open[6]);

}
//+------------------------------------------------------------------+
```

but 6° candle return me error value   ,because the result is 3,999999999      but  open  value  is  0.99104  and close vale  is 0.99108

why???

Files:
why.jpg 112 kb
160865

faustf:

hi guys  i try to do a simply script

but 6° candle return me error value   ,because the result is 3,999999999      but  open  value  is  0.99104  and close vale  is 0.99108

why???

The result is 3,999999999992898e-5 which is 0.00003999999999992898

1853

Try this code

`Comment (NormalizeDouble(Close[6]-Open[6], Digits());`
20248

amrali: Try this code
Try that code and get the same result. Floating point has infinite number of decimals, it's your not understanding floating point and that some numbers can't be represented exactly. (like 1/10.)
Double-precision floating-point format - Wikipedia, the free encyclopedia

Print out your values to the precision you want with DoubleToString - Conversion Functions - MQL4 Reference.