Convert int to double by adding decimals

 

int a = 3 (input) digits

how can i get double b = 0.001 (output) ticksize using int a =3

it means add 3 decimals in format 0.001 which is used for ticksize


I am using

         if(digit==1) tickSize = 0.1;
         if(digit==2) tickSize = 0.01;
         if(digit==3) tickSize = 0.001;
         if(digit==4) tickSize = 0.0001;
         if(digit==5) tickSize = 0.00001;
         if(digit==6) tickSize = 0.000001;
         if(digit==7) tickSize = 0.0000001;
         if(digit==8) tickSize = 0.00000001;


but i am looking for mathematical solution,

thanks

 
tickSize=1.0/pow(10,digit);

See MathPow().

Documentation on MQL5: Math Functions / MathPow
Documentation on MQL5: Math Functions / MathPow
  • www.mql5.com
MathPow - Math Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Haruto Rat #:

See MathPow().

Can be simplified a bit:

pow(10,-digit)
 
This is incorrect way to process tick size which can be different from a power of 10.