# A mathematical bug

Bugs will be moved here once resolved.

### » Mon Oct 06, 2014 11:05 am

codah wrote:ok man that's cool! sorry for the smiley face It looks great.

Thanks
B
8
S
3
Posts: 22
Reputation: 744

### » Mon Oct 06, 2014 11:14 am

You can get around that (sort of) ...

In Python I can write Round(Variable2, 4), when 4 represents the amount of decimal places which the software needs to round.
It is equal to (Variable2 * 10000) / 10000

Does anyone know if there is anything like that in C2?
B
8
S
3
Posts: 22
Reputation: 744

### » Mon Oct 06, 2014 12:20 pm

Closing, @spacedoubt is correct. This rounding happens in the floating point representation at the CPU level and it basically affects all software universally.
Scirra Founder
B
415
S
248
G
92
Posts: 25,288
Reputation: 200,960

### » Mon Oct 06, 2014 1:51 pm

SES wrote:You can get around that (sort of) ...

In Python I can write Round(Variable2, 4), when 4 represents the amount of decimal places which the software needs to round.
It is equal to (Variable2 * 10000) / 10000

Does anyone know if there is anything like that in C2?

I think int(variable2*10000)/10000

Also rounding errors can happen for storing decimals by themselves (some decimal numbers have not a finite number of decimals in binary), also, a negative number like -0.2 is not represented the same way as 0.2, which involves calculations and potential errors too.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
54
S
23
G
18
Posts: 2,123
Reputation: 17,200

### » Tue Oct 07, 2014 12:15 am

It is still very accurate though. The error is at the 17th decimal place. The only inconvenience is making the number look cleaner when displaying it, which Aphrodite's equation will do.
B
101
S
39
G
134
Posts: 5,590
Reputation: 85,518

Previous