Skip to content

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

@fdsc

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)

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