tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: detecting integer over/underflow

In article <>,
Sad Clouds  <> wrote:
>OK so given
>int32_t n32;
>uint64_t n64;
>int32_t n32_result;
>n32_result = (uint64_t)n32 + n64;
>Are you checking that
>1) 64-bit sum will not be truncated and will fit into 32-bit variable,
>2) 64-bit sum will not overflow 64-bits before it is assigned (and
>possibly truncated) to 32-bit variable, or
>3) check both

Only 1)


Home | Main Index | Thread Index | Old Index