<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">> Should `a + (b - c)` be the same as `(a + b) - c`? You either need a signed type or wrapping to have reasonable answers here<br></div><div dir="ltr"><br></div><div>Depending on what "reasonable" means here, only wrapping (unsigned in C) gets you this commutative property. For a signed value with C, it's possible for one of these to be undefined behavior, while the other returns a reasonable value. For instance, `a == b == c == std::<span style="color:rgb(0,0,0);font-size:12.800000190734863px"> numeric_limits<</span>typeof(a)>::min()` is probably unusual as a value, but could be used as a sentinel (perhaps to represent an infinite or empty set). Of course, the unsigned result might just be nonsense.<br></div><div><br></div><div>Anyways, I don't have a strong opinion either way, since I think they both can have surprises.</div><div><br></div><div>One other occasional benefit to using unsigned that can be surprising is that power-of-two division is slightly cheaper (since it doesn't need to handle negative numbers):</div><div><br></div><div>(ssize_t)x / 2</div><div><div><span class="gmail-Apple-tab-span" style="white-space:pre">    </span>shrq<span class="gmail-Apple-tab-span" style="white-space:pre">  </span>$63, %rax</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">      </span>leaq<span class="gmail-Apple-tab-span" style="white-space:pre">  </span>(%rax,%rdi), %rax</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">      </span>sarq<span class="gmail-Apple-tab-span" style="white-space:pre">  </span>%rax</div></div><div><br></div><div>(size_t)x / 2<br></div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>shrq<span class="gmail-Apple-tab-span" style="white-space:pre">  </span>%rdi</div></div></div><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">> is there any container</blockquote><div><br></div><div>I'd posit that UINT_MAX is uncommon, but pretty easy to exceed (although it needs a 64-bit machine to represent it). For example, anything that might need to handle the return value of `MemoryBuffer::getFile` could come across a file that's larger than 2GB.</div></div></div></div></div></div>