Quote #519 My Favorite PL/I Type Conversion Example

HomeFortune CookiesQuotations - Random

Quote #519

My favorite PL/I type conversion example:
Declare A, B, and C as three-character strings. B='123';C='456';A=B+C;
What does A contain? PL/I automatically coerces strings to decimal numbers
in arithmetic context, so it correctly converts B and C and adds them to
get 579. Then it converts it back to a string of a default length,
which is ' 579'. Then it truncates the string from the right, so the
result is ' '. Oops. -John

Related: