Skip to content

Explain numeric widths, unsigned/signed integers, and overflow/underflow #486

@rhagenson

Description

@rhagenson

We have previously assumed a more expansive numeric type knowledge for Pony learners. Pony can be the first language where a developer must consider numeric issues such as numeric widths, signed vs unsigned integers, and overflow/underflow so the Arithmetic section of the Tutorial should include explanations of these topics.

We suggest this additional content be placed early in the section prior to any mention of these terms and provide a link for those already familiar with these topics to skip ahead to where the presumption of this knowledge begins (that is, the continuation of current content). This additional content must include examples involving the bounds of numerics -- minimum and maximum values at a given width, involvement of zero for signed and unsigned integers, and how underflow/overflow interacts with the former two topics.

For example:

// Unsigned integers, as many would be familiar with, but with possibly unfamiliar wraparound
U8(0) - 1 == 255

// Unsigned integers, as many would be familiar with, but with possibly unfamiliar wraparound
U8(255) + 1 == 0

// Signed integers, where wraparound does not occur at zero
I8(0) - 1 == -1

// Signed integers, where wraparound does not occur at zero
I8(-128) - 1 == 127

The examples will be ideally short, however should cover all topics to ensure explicitly addressing the interaction between numeric issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions