1 / 20

The fundamental data type

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 참고 ).

ossie
Télécharger la présentation

The fundamental data type

An Image/Link below is provided (as is) to download presentation 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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The fundamental data type 제4주 강의

  2. 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 참고)

  3. Expressions • Meaningful combinations of constants, variables, operators, and function calls • a+b 5.0*x – tan(9.0/x) • Page 689 참고

  4. Assignments • variable = expr ; • Page 689 참고 • 숙제 ::: a=b=c+d=e  이것이 정상적인 assignment statement임을 문법을 참고로 증명하라!!! 적용된 문법을 보일 것

  5. The fundamental data types • Declaration ::= type identifier {, identifier}0+ ;

  6. Long form • fundamental types • array, pointer, structure ::: derived types

  7. Widely used form • ‘int’ can be omitted

  8. Functionality

  9. 3.3 Characters and the Data Type char • getchar(), putchar() • 8bits (28 =256) • 대문자, 소문자, 숫자, 구두점, 특수문자 • White space characters는 포함 • 제어문자는 제외 • ASCII, EBCDIC

  10. ASCII

  11. Special characters

  12. 출력 • printf(“%c”, ‘\a’) ;  putchar(‘\a’) • printf(“%\”abc\””) ; “abc” • printf(“%cabc%c”, ‘\’’,’\’’) ;  ‘abc’

  13. 출력 예 • 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’

  14. Integer • 32bits : -231, -231+1 … -1, 0, 1, … … 231-1 • 16bits : -215, -215+1 … -1, 0, 1, … … 215-1 • Nmin_int ≤ i ≤ Nmax_int

  15. Short, long, unsigned • short  16bits • long  32bits • unsigned  32bits 기계: Nmax_unsigned = 232 -1 (일부시스템) 16bits 기계: Nmax_unsigned = 216 –1 (일부시스템) = 65535 •  16bits 기계  32000(short), 33000(long)

  16. 상수표현 방법

  17. The floating types • Float, double, long double

  18. 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으로 구현

  19. The use of typedef • typedef char uppercase typedef int INCHES, FEET; typedef unsigned long size_t; • uppercase u; INCHES length, width;

  20. 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)

More Related