Skip to content

The description of the behaviour of "default" and unsafe arithmetic is unclear, especially the term wrap around #425

Description

@fdsc

In https://tutorial.ponylang.io/expressions/arithmetic.html

  • | add() | wrap around on over-/underflow
    +~ | add_unsafe() | Overflow E.g. I32.max_value() +~ I32(1)

But I see
var x10 = U32.max_value() + 1
env.out.print("U32.max_value() + 1: " + x10.string()) // print 0

x10 = U32.max_value() +~ U32(1)
env.out.print("U32.max_value() +~ 1: " + x10.string()) // 4294967295

That is, "+~" is performed without overflow, but "+" - with overflow

ponyc -v
0.33.2-aff95ec [release]
(windows 7 x64)

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