# Construct 2 can't calculate?..

Get help using Construct 2

### » Mon Feb 23, 2015 8:48 am

I am sure it can, but here is my problem when I ask construct 2 to do this
(36.00360037-36) I get this 0.003600370000000908
But what I want is 0.00360037

What am I doing wrong here?

In case you wonder why I want that. It is a code who reads out every number to create a certain situation
The amount of zeros in between are so that when it rounds it down/up I wont get a different number.
But I tested this with simply and only asking C2 to do this (36.00360037-36) on a empty layout with no events.
B
7
S
2
Posts: 144
Reputation: 1,081

### » Mon Feb 23, 2015 8:57 am

There was a discussion here recently and the basic idea is that "on computers floating point numbers are never exact" - so you cannot be sure of the number of digits after the point.

If the number of digits is always the same you could do something like Result = left(str(36.00360037-36,NumberOfDigitsYouNeed)) else you could rethink the approach.
B
19
S
6
G
7
Posts: 1,101
Reputation: 6,146

### » Mon Feb 23, 2015 9:18 am

Somebody is perfectly right. C2 is fine works wonder for me
B
269
S
52
G
16
Posts: 2,045
Reputation: 44,140

### » Mon Feb 23, 2015 10:45 am

See "Expecting math calculations to be exact" in common mis-used events and gotchas.
Scirra Founder
B
415
S
248
G
92
Posts: 25,295
Reputation: 200,984

### » Mon Feb 23, 2015 11:35 am

OK i understand how it works. I'll try a different wat.
B
7
S
2
Posts: 144
Reputation: 1,081

### » Mon Feb 23, 2015 3:54 pm

Maybe you can help me. What I want is certain id to be picked. I know how to do it, however the problem is that I need like 10 different Id or more to be picked. I would to give a code. for example 353627 and that Id 35 ,36 ,27 will be picked. They are all the same object. And I need the id to be different for each level. I can't do it manually since every level is the same layout and event sheet but different variables. That is been passed on the moment the player clicks level* .

I tried so many things but I can't get it to work. Maybe you guys have an idea. I know it isn't easy(at least not for me). Thanks so far for the help.
B
7
S
2
Posts: 144
Reputation: 1,081

### » Mon Feb 23, 2015 6:10 pm

This is what I did so far and it works almost perfect since I can only do it for a max amount of numbers. If I use more C2 can't handle the amount. So I would have to keep repeating this method. Maybe someone has a better idea.
B
7
S
2
Posts: 144
Reputation: 1,081

### » Tue Feb 24, 2015 12:07 pm

bump
B
7
S
2
Posts: 144
Reputation: 1,081

### » Tue Feb 24, 2015 12:20 pm

Furdy wrote:

This is what I did so far and it works almost perfect since I can only do it for a max amount of numbers. If I use more C2 can't handle the amount. So I would have to keep repeating this method. Maybe someone has a better idea.

A sample capx would help us understand what you are doing and what you are trying to achieve.

Are you trying to make a random map generator? If so, there are some good examples on the forums.
B
9
S
2
Posts: 80
Reputation: 864

### » Tue Feb 24, 2015 8:42 pm

What I have is a grid of blocks. For example 6x7. So 42 blocks. Certain blocks I want to be grey. I use Id from the blocks to chose wich one. Different for each level. So I cannot place them manually since every level is on the same layout. What you see on screenshots above is the best solution I can think of. Thanks for helping.
B
7
S
2
Posts: 144
Reputation: 1,081

Next