# Problem with having two decimal points with "add to" action

Get help using Construct 2

### » Tue Jun 17, 2014 9:32 pm

I have a global variable "Number" as 0, and object "Button"

SO, every time "Button" is touched, then 0,01 is added to "Number".
-->
On Touched "Button" --> Add 0,01 to Number

Problem occurs when i touch "Button" after 5th time, then this happens:

Number = 0 --> 0,01 --> 0,02, --> 0,03 --> 0,04 --> 0,05 --> 0.060000000000000005 --> 0,07 --> ...

Problem occurs with 5th addition, it gives me 18 numbers after decimal point.

Can anyone help me with understanding why this happens, and how to prevent it?

Idea in the game is to compare two numbers. First function gives me number with two numbers after decimal point (floor(random(1,10000))/100), and i have to get equal number with touching "Button". But this problem prevents to achieve my goal
B
3
S
1
Posts: 4
Reputation: 340

### » Tue Jun 17, 2014 9:51 pm

Okay, found a solution.

Decimals in a Float
B
3
S
1
Posts: 4
Reputation: 340