8000 Order of operations in integer arithmetic is wrong · Issue #976 · inkle/ink · GitHub
[go: up one dir, main page]

Skip to content

Order of operations in integer arithmetic is wrong #976

Open

Description

@Zarkonnen

Reproduce
{ 10 * 8 / 10 }

Expected Output
8

Observed Output
0

Workaround
{ (10 * 8) / 10 }

I'd expect the order of operations to go left to right, as is generally the case with other environments/programming languages. Unfortunately, fixing this might break existing Ink scripts that rely on this behavior. Also unfortunately, there's probably a lot of scripts out in the while that have bugs in them because of this bug.

Addendum
Looking at the following examples, it seems that the problem is that division has a higher priority than multiplication, which it shouldn't:

  • Forcing right-to-left evaluation: { 10 / (2 * 2) } -> 2
  • Forcing left-to-right evaluation: { (10 / 2) * 2 } -> 10
  • Without brackets: { 10 / 2 * 2 } -> 10

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0