# Problem/bug with array and decimals

Get help using Construct 2

### » Sat Aug 15, 2015 4:17 pm

I don't know what happen but when I use array C2 say:
0.05 + 0.01 = 0.060000000000000005

Example:
https://dl.dropboxusercontent.com/u/128712958/test.capx

Source code:

Result:

Thank you.
B
10
S
5
G
1
Posts: 28
Reputation: 1,456

### » Sat Aug 15, 2015 5:01 pm

That's the problem with floating point numbers...

B
55
S
29
G
19
Posts: 1,520
Reputation: 25,870

### » Sat Aug 15, 2015 5:39 pm

And is there any easy solution?
B
10
S
5
G
1
Posts: 28
Reputation: 1,456

### » Sat Aug 15, 2015 5:42 pm

Stick with integers and divide by 100 only when you need to get the value as a decimal.
B
72
S
22
G
290
Posts: 3,884
Reputation: 159,509

### » Sat Aug 15, 2015 5:54 pm

most certainly not the best way...but

test.capx
B
67
S
24
G
7
Posts: 1,519
Reputation: 11,104

### » Sat Aug 15, 2015 6:08 pm

Like @blackhornet said, work with integers:

B
15
S
6
Posts: 105
Reputation: 1,356

### » Sat Aug 15, 2015 6:27 pm

I decide to use the *100 /100 solution, but adding a round().
With this I can use the array and I don't need to worry every time to add a /100
B
10
S
5
G
1
Posts: 28
Reputation: 1,456