Cannot get to Print to Screen a Very Simple Double Value??

 

Hi All,

I've been staring at this for the last hour and cannot fathom why I cannot get the value of =6/100 to Print to screen. It keeps Printing as zero?

I've tried 4 different ways to print to the screen but they all don't work and obviously something I'm not doing correctly.

   lookbackLength = 6;
   Print("HERE");
   Print("lookbackLength: ",lookbackLength);
   double temp = lookbackLength/100;
   Print("1 (lookbackLength/100): ", temp);
   Print("2 (lookbackLength/100): ", DoubleToString(temp,4));
   Print("3 (lookbackLength/100): ", NormalizeDouble(temp,4));
   Print("4 (lookbackLength/100): ", DoubleToStr(temp,4));

And these are my outputs:

2020.05.15 09:25:34.414 9_Martingale_SmallTargetLargeStop_8AddIns CADCHF,Daily: HERE
2020.05.15 09:25:34.414 9_Martingale_SmallTargetLargeStop_8AddIns CADCHF,Daily: lookbackLength: 6
2020.05.15 09:25:34.414 9_Martingale_SmallTargetLargeStop_8AddIns CADCHF,Daily: 1 (lookbackLength/100): 0.0
2020.05.15 09:25:34.414 9_Martingale_SmallTargetLargeStop_8AddIns CADCHF,Daily: 2 (lookbackLength/100): 0.0000
2020.05.15 09:25:34.414 9_Martingale_SmallTargetLargeStop_8AddIns CADCHF,Daily: 3 (lookbackLength/100): 0.0
2020.05.15 09:25:34.414 9_Martingale_SmallTargetLargeStop_8AddIns CADCHF,Daily: 4 (lookbackLength/100): 0.0000

You can see that the Printed value is always zero. I'm pretty sure that 6/100 is 0.06 though?


Please any help is really appreciated.

 

CarlRostron:

 I'm pretty sure that 6/100 is 0.06 though?

it is cast to an int.

Try 6/100.0

 

Bingo!!


Seriously - I'd never have thought of that.


Really appreciate your help, genuinely.


I'll keep my eye out for that Rookie mistake in the future.


Enjoy your weekend my friend.

 
CarlRostron: . I'm pretty sure that 6/100 is 0.06 though?

No.
          On MT4 v434, division quotient don't give floating point values(Bug??) - MQL4 programming forum 2012.09.18