Construct has sporadic issues dividing?

This forum is currently in read-only mode.
From the Asset Store
Casino? money? who knows? but the target is the same!
  • I'm not sure if this is a bug, or... well, I don't really know. If it's a bug I can repost in on the bug tracker. What's happening is Construct very sporadically stops dividing numbers properly. I'll divide 1 / 100 and get 0.00999999658 or something.

    I noticed the problem and found out what was happening one time when I attempted a quick bandaid on an unrelated problem I was having by changing the window resolution during a layout transition. When I did this, Construct ceased to divide properly at all, no matter what. Without me doing this, it works correctly MOST of the time. Otherwise, I've tried really hard to repro or determine the pattern of how/why it stops dividing properly, but no go.

    I have no idea, is it Construct? Is it my computer? Anybody have any ideas?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I forgot to add it DOES happen to my other testers with versions compiled on my computer.

  • They're called rounding errors.

    This isn't a problem with construct - it's a problem with how computers are designed. People working with other languages have to deal with it too.

    The simple explanation - CPUs don't have enough precision to calculate floats (decimals) exactly right, so you often get results like the one you posted.

    You can count integers being exact, like 1+1 equaling 2, but you cannot count on 0.1+0.1 equaling 0.2.

    Either don't use conditions that require exact floats, or when checking the variable make it an integer instead, like if a variable is 0.1, use "if round(variable*10)=1" instead.

  • This was an extremely helpful answer but it was also not the answer I wanted.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)