When I try to convert string "1.12345" to a double I receive 1.1235 as a result (only 4 digits after point and the number is rounded). Is it possible to convert the string to a double without truncating and rounding like this:
double Price = StrToDouble("1.12345");
// Price = 1.12345 instead of 1.1235
I see I need to change default formatting for display. The number is converted properly. Sorry for bother.
When I try to convert string "1.12345" to a double I receive 1.1235 as a result (only 4 digits after point and the number is rounded). Is it possible to convert the string to a double without truncating and rounding like this:
double Price = StrToDouble("1.12345");
// Price = 1.12345 instead of 1.1235
When you try to convert "1.12345" you will receive 1.12345 as a result. There is no any truncation or rounding.
The problem is that you are using the standard output with 4 significant digits.
For example, code:
#include <stdlib.mqh> int start() { double Price = StrToDouble("1.12345"); Alert("Standard output:",Price,", 8-digits:",DoubleToStr(Price,8),", 15-digits:",DoubleToStrMorePrecision(Price,15)); }will output:
Standard output:1.1235, 8-digits:1.12345000, 15-digits:1.123450000000000
So if you want to control the values it is better to use the functions DoubleToStr and DoubleToStrMorePrecision (see stdlib.mqh)

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
When I try to convert string "1.12345" to a double I receive 1.1235 as a result (only 4 digits after point and the number is rounded). Is it possible to convert the string to a double without truncating and rounding like this:
double Price = StrToDouble("1.12345");
// Price = 1.12345 instead of 1.1235