How to get Decimal Value?

 

Hello

I want to extract a decimal value ( for eg: I want to get 0.1234 from 15482.1234). Please advice me how to code it.

Thanks and Regds

mithetnme

 
double x=15482.1234,
       y=1;
double z=MathMod(x,y);
 

19730719:

double x=15482.1234,
       y=1

double z=MathMod(x,y);



Hello

Thanks for your calculation. I think there is no mql4 command to directly get a decimal value . So your way is a good n simple to get what I want.

1000000 thanks

mithetnme

 
19730719:

Thanks, very helpful.

 
Saw Khine: I think there is no mql4 command to directly get a decimal value .
double value    = 15482.1234;
double fraction = value - int(value);   // 0.1234
 
whroeder1:
double value    = 15482.1234;
double fraction = value - double(int(value));   // 0.1234

Always best to get in the habit of making sure all numbers are double in floating-point arithmetic 'cuz bad-habits will bite ya sooner or later. 

 
Ints enlarge to double as defined by the defined priority scheme. I may be anal-retentive but stating the obvious is ridiculous, such as adding unnecessary parentheses, e.g. v + (v1 * v2).
 
whroeder1:
Ints enlarge to double as defined by the defined priority scheme. I may be anal-retentive but stating the obvious is ridiculous, such as adding unnecessary parentheses, e.g. v + (v1 * v2).
I was plagued by a bug where it didn't. You know how difficult it was too find? Never again. #goodhabits
Reason: