The fundamental data type

1 / 20

# The fundamental data type - PowerPoint PPT Presentation

The fundamental data type. 제 4 주 강의. Declarations, Expressions, and Assignments. Declaring the type of a variable  set an appropriate amount of space in memory by a compiler  deciding appropriate operations  checking invalid operations and operands (686page 참고 ).

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about 'The fundamental data type' - ossie

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

### The fundamental data type

제4주 강의

Declarations, Expressions, and Assignments
• Declaring the type of a variable

 set an appropriate amount of space in memory by a compiler

 deciding appropriate operations

 checking invalid operations and operands

(686page 참고)

Expressions
• Meaningful combinations of constants, variables, operators, and function calls
• a+b

5.0*x – tan(9.0/x)

• Page 689 참고
Assignments
• variable = expr ;
• Page 689 참고
• 숙제 :::

a=b=c+d=e  이것이 정상적인 assignment statement임을 문법을

참고로 증명하라!!! 적용된 문법을 보일 것

The fundamental data types
• Declaration ::=

type identifier {, identifier}0+ ;

Long form
• fundamental types
• array, pointer, structure ::: derived types
Widely used form
• ‘int’ can be omitted
3.3 Characters and the Data Type char
• getchar(), putchar()
• 8bits (28 =256)
• 대문자, 소문자, 숫자, 구두점, 특수문자
• White space characters는 포함
• 제어문자는 제외
• ASCII, EBCDIC
출력
• printf(“%c”, ‘\a’) ;  putchar(‘\a’)
• printf(“%\”abc\””) ;

“abc”

• printf(“%cabc%c”, ‘\’’,’\’’) ;

 ‘abc’

출력 예
• int c; int i;
• for (i=‘a’; i<=‘z’;++i)

printf(“%c”,i); /* abc …z */

• for (c=65; c<=90;++c)

printf(“%c”,c); /* ABC … Z */

• for (c=‘0’; c<=‘9’;++c)

printf(“%d”,c); /* 48 49 … 57 */

• 01100001(2) == 97 == ‘a’
Integer
• 32bits : -231, -231+1 … -1, 0, 1, …

… 231-1

• 16bits : -215, -215+1 … -1, 0, 1, …

… 215-1

• Nmin_int ≤ i ≤ Nmax_int
Short, long, unsigned
• short  16bits
• long  32bits
• unsigned 

32bits 기계: Nmax_unsigned = 232 -1 (일부시스템)

16bits 기계: Nmax_unsigned = 216 –1 (일부시스템)

= 65535

•  16bits 기계  32000(short), 33000(long)
The floating types
• Float, double, long double
Floating point 값의 표현
• Precision, range
• float 

0.d1d2…d6 x 10n (-38 ≤ n≤ 38)

• double 

0.d1d2…d15 x 10n (-308 ≤ n≤ 308)

• 123.45123451234512345 

0.123451234512345 x 10+3 (유효숫자 15)

• long double  long으로 구현
The use of typedef
• typedef char uppercase

typedef int INCHES, FEET;

typedef unsigned long size_t;

• uppercase u;

INCHES length, width;

The sizeof Operator
• sizeof(object)
• sizeof(char)  1
• sizeof(char) ≤ sizeof(short) ≤ sizeof(int) ≤ sizeof(long)
• sizeof(signed) = sizeof(unsigned) = sizeof(int)
• sizeof(float) ≤ sizeof(double) ≤ sizeof(long double)