Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
unsigned long int ul = ULONG_MAX;
signed carchar sc;
if (i <= SCHAR_MAX) {
  sc = (signed char)ul;  /* use cast to eliminate warning */
}
else {
	/* handle error condition */
}

...

Code Block
signed long int sl = LONG_MAX;
signed carchar sc;
sc = (signed char)sl; /* cast eliminates warning */

...

Code Block
signed long int sl = LONG_MAX;
signed carchar sc;
if ( (sl < SCHAR_MIN) || (sl > SCHAR_MAX) ) {
	/* handle error condition */
}
else {
	sc = (signed char)sl; /* use cast to eliminate warning */
}

...

Code Block
unsigned long int ul = ULONG_MAX;
unsigned carchar uc;
uc = (unsigned char)ul;  /* cast eliminates warning */

...

Code Block
unsigned long int ul = ULONG_MAX;
unsigned carchar uc;
if (ul > UCHAR_MAX) ) {
	/* handle error condition */
}
else {
	uc = (unsigned char)ul; /* use cast to eliminate warning */
}

...