# Game maker, issues with an equation

Hello I am having an issue getting this equation to work, even with manually entering values replacing the variables. I cannot seem to get it to work, I have tested that the variables are being updated and working correctly and simpler equations are working and are able to be drawn, but when i try this all i am getting is "0.00"

yes this is working out profit made from bitcoin mining.

The original equation i am trying to get to work is dailyprofit = 24/(d*2^32/(h*10^6)/60/60)*c

global.profit =(24/(global.difficulty * power(2,32)/(global.hashrate * power(10,6))/60/60)*global.reward);


any help or ideas would be greatly appreciated.

• Are you accidentally doing integer division at some point? – congusbongus Dec 31 '13 at 4:44
• I am sorry i am not 100% sure as to what you mean. Though possibly the '24/' at the beginning, when removed it gives me the wrong result but i do get a result. – user913627 Dec 31 '13 at 5:32
• Try breaking up the calculation into multiple steps and printing out the value after each step. Better yet, if GM has some sort of a debugger -- use that! – Martin Green Dec 31 '13 at 9:47

You may have accidentally done integer division, which is division that returns an integer - the number that you expected from the division is truncated (which in this context effectively means rounded down) thus yielding 0.0 as the result of the equation.

To fix this, replace all of the "24"s in the equation with "24.0"s.

I'm not sure how GM handles this kind of thing, so it may not be the problem, but it's my best guess as to what's going on, Python does this kind of thing when you don't use a .x in a division.

Thank you all for you help, and sorry. The error I found to be the cause was not to do with the equation itself. Game maker does not automatically draw more than 2 decimal places and this issue was resolved as below.

x=string_format(global.profit,0,6)