Double object is not initializing as expected

 

Hi, I have initialized the double object as:


But when I see it on debugger watch, I get this

what could be the possible reason for getting this small fraction? 

 
Salman Ahmed:

Hi, I have initialized the double object as:


But when I see it on debugger watch, I get this

what could be the possible reason for getting this small fraction? 

Please, study this:

https://www.mql5.com/en/docs/basis/types/double

Documentation on MQL5: Language Basics / Data Types / Real Types (double, float)
Documentation on MQL5: Language Basics / Data Types / Real Types (double, float)
  • www.mql5.com
Real types (or floating-point types) represent values with a fractional part. In the MQL5 language there are two types for floating point numbers.The method of representation of real numbers in the computer memory is defined by the IEEE 754 standard and is independent of platforms, operating systems or programming languages. Floating-point...
 
Andrey Barinov:

Please, study this:

https://www.mql5.com/en/docs/basis/types/double

Thank you for your reply, I understand what is the problem and solution. but now my question is: this is not a case in MQL4, why it is working perfectly in MQL4?

 
Salman Ahmed: what could be the possible reason for getting this small fraction? 
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

See also The == operand. - MQL4 programming forum

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