Skip to content

CONST applies negation higher than exponentiation #196

Closed
@mkilgore

Description

@mkilgore

CONST evaluates -2 ^ 2 as (-2) ^ 2 and thus gives 4. However, if you actually evaluate this expression in Ex. a PRINT statement you'll find it evaluates to -4 because QB64's order of operations treat that as -(2 ^ 2), exponentiation is higher then negation.

I'm considering this a bug since CONST should have the same operator order as regular QB64 (IE. Any expression evaluated as CONST should give exactly the same value as evaluating it as a non-CONST), but it's notable that exponents are not allowed to be in CONST expressions in QB45 for some reason, so this is not a compatibility issue with QB45.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    • Status

      Done

    Milestone

    No milestone

    Relationships

    None yet

    Participants

    @mkilgore

    Issue actions

      CONST applies negation higher than exponentiation · Issue #196 · QB64-Phoenix-Edition/QB64pe