Skip to content
Better HN
Top
New
Best
Ask
Show
Jobs
Search
⌘K
undefined | Better HN
0 points
einpoklum
8d ago
0 comments
Share
>
Unsigned ints have no “negativity” semantic.
They do. The code:
unsigned x; unsigned y = -x;
is well-defined in C and C++. See this discussion on StackOverflow for spec text and reference:
https://stackoverflow.com/q/8026694/1593077
0 comments
default
newest
oldest
throwaway894345
8d ago
That’s not a negativity semantic, it’s the behavior of the “-“ operator. If you print y or compare it to zero you will see that the result remains positive. Unsigned integers by definition have no negative semantic, hence the name.
j
/
k
navigate · click thread line to collapse