A mathematical bug

Bugs will be moved here once resolved.

Post » Mon Oct 06, 2014 11:05 am

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


:D Thanks
B
8
S
3
Posts: 22
Reputation: 744

Post » 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

Post » 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
398
S
236
G
88
Posts: 24,442
Reputation: 194,683

Post » 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
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » 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
92
S
32
G
110
Posts: 5,298
Reputation: 71,507

Previous

Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 7 guests