Skip to content

i8 literals and friends have incorrect ranges #2438

Closed
@bstrie

Description

@bstrie

https://gist.github.com/2783543

The maximum legal value of signed integers of length x should be (2^(x-1)) - 1, but in most cases Rust allows signed literals of value 2^(x-1), but then interprets those literals as the minimum legal value (see the output in the gist above).

The exception is i16, which exhibits the same behavior as above, except that, bafflingly, x is 12 rather than 16.

EDIT: wrong equations

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