[QUESTION] Usage of negative number notations on unsigned numbers.
Andreas Schwab
schwab at linux-m68k.org
Fri Nov 24 03:08:49 PST 2023
On Nov 24 2023, Karthik B K wrote:
> If so, isn't it safer to use (~0UL) ? This could be a very silent bug. Please correct me if I'm wrong.
The safest way is to write -1 without any suffix. This is guaranteed to
evaluate to the maximum value when converted to any unsigned type.
--
Andreas Schwab, schwab at linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
More information about the opensbi
mailing list