Skip to content

0.0 treated as -0.0 in VM, depending on order, causing further differences bw RT and CT #16469

@timotheecour

Description

@timotheecour

-0.0 == 0.0 but that shouldn't mean they're interchangeable; see example below; in particular conflating these breaks further math such as 1/x being inf vs -inf, or breaks things relying on copySign (#16406)

Example

when true:
  proc main =
    let a1 = 0.0
    let a2 = -0.0
    let a3 = 1.0 / a1
    let a4 = 1.0 / a2
    echo (a1, a2, a3, a4)
  static: main()
  main()

Current Output

(0.0, 0.0, inf, inf)
(0.0, -0.0, inf, -inf)

Expected Output

(0.0, -0.0, inf, -inf)
(0.0, -0.0, inf, -inf)

Additional Information

Metadata

Metadata

Assignees

No one assigned

    Labels

    VMsee also `const` label

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions