The fundamental data type
This presentation is the property of its rightful owner.
Sponsored Links
1 / 20

The fundamental data type PowerPoint PPT Presentation


  • 46 Views
  • Uploaded on
  • Presentation posted in: General

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

Download Presentation

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

The fundamental data type

제4주 강의


Declarations expressions and assignments

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

Expressions

  • Meaningful combinations of constants, variables, operators, and function calls

  • a+b

    5.0*x – tan(9.0/x)

  • Page 689 참고


Assignments

Assignments

  • variable = expr ;

  • Page 689 참고

  • 숙제 :::

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

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


The fundamental data types

The fundamental data types

  • Declaration ::=

    type identifier {, identifier}0+ ;


Long form

Long form

  • fundamental types

  • array, pointer, structure ::: derived types


Widely used form

Widely used form

  • ‘int’ can be omitted


Functionality

Functionality


3 3 characters and the data type char

3.3 Characters and the Data Type char

  • getchar(), putchar()

  • 8bits (28 =256)

  • 대문자, 소문자, 숫자, 구두점, 특수문자

  • White space characters는 포함

  • 제어문자는 제외

  • ASCII, EBCDIC


Ascii

ASCII


Special characters

Special characters


The fundamental data type

출력

  • printf(“%c”, ‘\a’) ;  putchar(‘\a’)

  • printf(“%\”abc\””) ;

    “abc”

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

     ‘abc’


The fundamental data type

출력 예

  • 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

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, long, unsigned

  • short  16bits

  • long  32bits

  • unsigned 

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

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

    = 65535

  •  16bits 기계  32000(short), 33000(long)


The fundamental data type

상수표현 방법


The floating types

The floating types

  • Float, double, long double


Floating point

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

The use of typedef

  • typedef char uppercase

    typedef int INCHES, FEET;

    typedef unsigned long size_t;

  • uppercase u;

    INCHES length, width;


The sizeof operator

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)


  • Login