It is the way typecasting works.
Try this:
void OnTick() { double x; x=(1/3.); Print("value =",x); }
You can read more about it here - https://docs.mql4.com/basis/types/casting

- docs.mql4.com
It is the way typecasting works.
Try this:
You can read more about it here - https://docs.mql4.com/basis/types/casting
can I have one more question please
void OnTick()
{
char c1=1,c2=3;
//--- First example
double d2=c1/c2+0.3;
Print("resultat = ",d2);
resultat = 0.3
why?
Division happens before addition... https://docs.mql4.com/basis/operations/rules
1/3 = 0
0 + 0.3 = 0.3
Try this:
void OnTick() { char c1=1,c2=3; //--- First example double d2=c1/(c2+0.3); Print("resultat = ",d2); }

- docs.mql4.com
Division happens before addition... https://docs.mql4.com/basis/operations/rules
1/3 = 0
0 + 0.3 = 0.3
Try this:
yes I know the basic of math but I solved the prob
can you look please
void OnTick()
{
char c1=1,c2=3;
//--- First example
double d2=c1/double(c2)+0.3);
Print("resultat = ",d2);
}
now resultat is 0.6333333333333
Your code doesn't compile... what answer are you expecting?
1/3. = 0.333
0.333 + 0.3 = 0.633
Your code doesn't compile... what answer are you expecting?
1/3. = 0.333
0.333 + 0.3 = 0.633
sorry there is a false bracket
double d2=c1/double(c2)+0.3);
yes 0.633
sorry there is a false bracket
double d2=c1/double(c2)+0.3);
yes 0.633
It's not bracket, it's parenthesis or ...
Forum on trading, automated trading systems and testing trading strategies
whroeder1, 2014.09.10 13:44
|
|
It's not bracket, it's parenthesis or ...



- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
void OnTick()
{
double x;
x=(1/3);
Print("value =",x);
}
the print value is 0. why????