Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: wordsmithing

...

A loss of data (truncation) can occur when converting from a signed type to a signed type with less precision. The following code can result in truncationresults in a truncation error on most implementations::

Code Block
bgColor#FFcccc
langc
#include <limits.h>

void func(void) {
  signed long int s_a = LONG_MAX;
  signed char sc = (signed char)s_a; /* Cast eliminates warning */
  /* ... */
}

...