The Department of Computer Science & Engineering |
STUART C. SHAPIRO: CSE
305
|
"6.3.1.4 Real floating and integer
- When a finite value of real floating type is converted to integer type other than
_Bool
, the fractional part is discarded (i.e., the value is truncated toward zero). If the value of the integral part cannot be represented by the integer type, the behavior is undefined."
[ISO C Standard ISO/IEC 9899:TC2, May 6, 2005, p. 43.]
Manual are written for programmers. They should specify all the operations, but some specifications may be implementation-dependent.
Testing can show you what one version of one compiler does.
For portable code, refer to the standard.
A
in the below C program?
#include <stdio.h> void sub() { int x = 2; printf("In sub, x = %d\n", x); } int main() { int x = 1; printf("In main, x = %d\n", x); A: sub(); printf("In main, x = %d\n", x); return 0; }
x
given the value
1
in the above C program?
This course will not be structured by these categories, but by PL components that all, or most, PLs have.