looking for a help for wrking with double

 
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
 

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:

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.

Wouldn't it be a lot easier just to do something like MathFloor(v * 10) / 10 ?
 
jjc:
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 ?

Each to their own I guess. My brain prefers the above. Probably flexibility at the expense of efficiency. :-)

CB

Reason: