i am a newbie in mql4.n i want to get the value of a double until fist decimal point without round. as an example lets take 0.72 and 0.78.then values should b 0.7 in both cases not 0.7 for first one and 0.8 for second one.so guys please help me for that
- Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6.
- [ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4.
- working with 106 decimals
Use DoubleToStr() and StrToDouble().
CB
cloudbreaker:
Use DoubleToStr() and StrToDouble().
CB
did not get the point properly any example please im very newbie in mql4 thats y im asking for such help.thanx in advance
You can use DoubleToStr() to convert the double into a string.
Then you can use StringSubstr() to collect the pieces of the string you wish to retain.
Depending upon how you choose to do the above you may use StringConcatenate() to stick together the pieces (if required).
Then use StrToDouble() to turn the string back into a double.
double myInputDouble = 0.78; double myOutputDouble = StrToDouble(StringSubstr(DoubleToStr(myInputDouble,2),0,3));
CB
cloudbreaker:
Wouldn't it be a lot easier just to do something like MathFloor(v * 10) / 10 ?
You can use DoubleToStr() to convert the double into a string.
Then you can use StringSubStr() to collect the pieces of the string you wish to retain.
jjc:
Wouldn't it be a lot easier just to do something like MathFloor(v * 10) / 10 ?
Wouldn't it be a lot easier just to do something like MathFloor(v * 10) / 10 ?
it wrks n simple thnx in advance
jjc:
Wouldn't it be a lot easier just to do something like MathFloor(v * 10) / 10 ?
Wouldn't it be a lot easier just to do something like MathFloor(v * 10) / 10 ?
Each to their own I guess. My brain prefers the above. Probably flexibility at the expense of efficiency. :-)
CB
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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