Download MetaTrader 5

so 4 / 100 = 0? how could i..

To add comments, please log in or register
Carry on your private correspondence in your profile. It is secure!
Subgenius
582
Subgenius 2015.08.27 05:56 

make a point decimal from two integers?


ive got two integer variables

iMultiplier 100 or 10000

and

iRange 4


i was hoping to divide the iRange by the iMultiplier to get the decimal of the price to add

or subtract from a price but what was happening is 0 and not 0.04..


just try

Print(4/100); the answer is 0

oh yea and also try Print(NormalizeDouble(4/100,2));

Keith Watford
Moderator
9625
Keith Watford 2015.08.27 06:24  
Subgenius:

just try

Print(4/100); the answer is 0

oh yea and also try Print(NormalizeDouble(4/100,2));

It is because the result is cast to an integer

try

4/100.0

so that 1 of the numbers is a double 

Subgenius
582
Subgenius 2015.08.27 06:28  
GumRai:

It is because the result is cast to an integer

try

4/100.0


thx

To add comments, please log in or register