From: Bonita.Montero@gmail.com   
      
   Am 20.10.2025 um 18:43 schrieb Michael S:   
   > On Mon, 20 Oct 2025 17:03:58 +0200   
   > pozz wrote:   
   >   
   >> After many years programming in C language, I'm always unsure if it   
   >> is safer to use signed int or unsigned int.   
   >>   
   >> Of course there are situations where signed or unsigned is clearly   
   >> better. For example, if the values could assume negative values,   
   >> signed int is the only solution. If you are manipulating single bits   
   >> (&, |, ^, <<, >>), unsigned ints are your friends.   
   >>   
   >> What about other situations? For example, what do you use for the "i"   
   >> loop variable?   
   >>   
   >   
   > I'd just point out that small negative numbers are FAR more common than   
   > numbers in range [2**31..2**32-1].   
      
   So use a short instead of an int for a loop counter to make the code   
   run faster on a 68000-CPU ? ;-)   
      
   > Now, make your own conclusion.   
   >   
   >   
   >> I recently activated gcc -Wsign-conversion option on a codebase and   
   >> received a lot of warnings. I started to fix them, usually   
   >> expliciting casting. Is it the way or is it better to avoid the   
   >> warning from the beginning, choosing the right signed or unsigned   
   >> type?   
   >>   
   >>   
   >   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|