Indexes are always non-negative, so I use size_twhere possible. Why is it usually to use signed integers? What is the reason for this?
size_t
I think this is mainly due to several reasons that work together:
int
unsigned
unsigned int
If you mean things like
for(int i=0; i<n; i++)
then there is no rationale. Sloppy, lazy programmers write sloppy code, just like that.
, . size_t, . uint_fastn_t, "n" , .
uint_fastn_t
0, , , . :
0
for (int i = n - 1; i >= 0; i--) { ... }
. , :
for (unsigned i = n; i-- > 0; ) { ... }
, unsigned: C, , .
The reason for the widespread use intis historical: it size_twas introduced at the end of the game and only became larger than unsignedrecently, with the exception of some older exotic systems.
Source: https://habr.com/ru/post/1656943/More articles:Rails 5 Failure Warnings - ruby-on-railsHow to combine TaskCompletionSource and CancellationTokenSource? - c #https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1656940/how-to-remove-when-writing-r-character-objects-to-json&usg=ALkJrhi1s2YiU9-zBUA5FbDEzvATlbA0JAHow to set line spacing for FormFields in iText? - pdf-generationPython: if Condition, then skip to return - pythonAngular 2: update FormControl validator after valueChanges - javascriptHow to clear certain TempData - c #Compare floats in Unity - floating-pointMapreduce's work using multithreading - multithreadinghttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1656948/create-responsive-arrow-that-adapts-to-height-of-element&usg=ALkJrhiC-4PeRik4s267-sl28lGIb18RgQAll Articles