Doubles and floats are not stored as exact values and normalization doesn't change that. Best to use calculated values for further calculations and StringSubstr(DoubleToString()) for human-readable output.
Also calculated float/double == other calculated float/double doesn't work, MathAbs(calculated double-calculated double))<0.000001 or something like that should be used.
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
Double-precision floating-point format - Wikipedia, the free encyclopedia
See also The == operand. - MQL4 and MetaTrader 4 - MQL4 programming forum
Print out your values to the precision you want with DoubleToString - Conversion Functions - MQL4 Reference.
whroeder1:
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
Thanks for your reply, please tell me if I want less presize value for example up to 5 decimal places then what data type should I use to store it. ThanksFloating 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 and MetaTrader 4 - MQL4 programming forum
Print out your values to the precision you want with DoubleToString - Conversion Functions - MQL4 Reference.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi all,
I am using BollingerBand in MQL5. When I copy values in buffer using CopyBuffer function, I got Un-Normalized values, which contains more then five decimal places. Moreover I explicitly tried to normalized them using NormalizeDouble and DoubleToString methods but both of them some time works fine but some time don't work.
I also use StringSubstr to get 5 or 3 decimal places depending on currency and append it with the part before decimal places but as soon as i put it in double variable it automatically append digits in it. for example:
1. initial value: 87.82087843203483
2. As it was AUDJPY pair, I picked till 3 digits after decimal: 87.820
3. Then I assign it double type variable and it becomes: 87.81999999999999
Why the datatype automatically rounding the value.
Please help.