[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Lost information converting decoded value to in32_t
From: |
Richard Frith-Macdonald |
Subject: |
Re: Lost information converting decoded value to in32_t |
Date: |
Tue, 26 May 2020 09:20:39 +0100 |
> On 25 May 2020, at 22:57, Riccardo Mottola <address@hidden> wrote:
> Looking up on the internet, I found the explanation is that the literal is
> only the number part without signed, regarless if it is a signed or unsigned
> decimal. Then the - operator is performed. For this reason it is usually
> written as (-2147483647 -1) in the limits header files.
> With that explanation, it is promoted to the "unsinged" type and then the "-"
> operation fails and underflows.
>
> For that reason I propose to change the lower bounds check to an equivalent
> easy to read
> if (big > 2147483647 || big + 2147483648 < 0
Great ... I copied that t NSPortCoder.m