home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 32,305 of 33,346   
   Kaba to Jeremy Todd   
   Re: taking abs() of min signed int value   
   17 May 12 06:45:44   
   
   c21e7739   
   From: kaba@nowhere.com   
      
   Jeremy Todd wrote:   
   > I need to compute the absolute value of the minimum signed int value   
   > for each signed integral type. This value isn't representable as a   
   > signed int, but it is representable as an unsigned int.   
      
   A way out of these problems is to never use the smallest value of a   
   signed integer. For example, if you store a sound signal in a 16bit   
   signed integer, use the range [-(2^16 - 1), 2^16 - 1]. The non-existence   
   of the additive inverse of -2^n makes the value unusable. From this   
   restriction follows other advantages such as being able to form a   
   bijection between the integer values and floating point numbers (useful   
   for lossless sound conversion between integers and floating point   
   numbers). Similarly for any data which is quantized from real numbers.   
      
   --   
   http://kaba.hilvi.org   
      
      
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca