Closed
Description
When going one above the max positive 32-bit integer, it overflows and becomes negative.
Example
Verbose for clarity; separators and type annotations don't change the outcome.
// Correct; this is a safe value.
let value: int = 2_147_483_647
// Incorrect; this gets transpiled to `-2_147_483_648`. Ideally, this should warn or error.
let value: int = 2_147_483_648
// Correct; this errors for not being a valid 32-bit integer.
let value: int = 2_147_483_649
Search Keywords
int, int32, sign, flip, 32-bit, integer limit, safe integer, integer overflow
Metadata
Metadata
Assignees
Labels
No labels