C Libraries: math and cytpe - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

C Libraries: math and cytpe

Description:

A library is a collection of related functions that have been compiled and ... double ceil(double x); Get the integer n such that n 1 x n. double floor(double x) ... – PowerPoint PPT presentation

Number of Views:46
Avg rating:3.0/5.0
Slides: 21
Provided by: peopl93
Category:
Tags: ceil | cytpe | libraries | math

less

Transcript and Presenter's Notes

Title: C Libraries: math and cytpe


1
C Libraries math and cytpe
  • Lecture 15 Mon, Sep 29, 2003

2
C Libraries
  • A library is a collection of related functions
    that have been compiled and stored in a .lib
    file.
  • C provides an extensive collection of
    libraries.
  • A library file may be added to a CodeWarrior
    project and linked to a program.
  • The corresponding header file should be included
    in the program.

3
The math Library
  • The math library contains most of the standard
    mathematical functions.
  • Include ltcmathgt in the .cpp file in which the
    functions are used.
  • A common error is to use a math function, but
    forget to include ltcmathgt.

4
The math Functions
  • double cos(double x)
  • Return cos x.
  • double sin(double x)
  • Return sin x.
  • double tan(double x)
  • Return tan x.

5
The math Functions
  • double acos(double x)
  • Return arccos x.
  • double asin(double x)
  • Return arcsin x.

6
The math Functions
  • double atan(double x)
  • Return arctan x in the range
  • ?/2 lt arctan x lt ?/2.
  • double atan2(double y, double x)
  • Return arctan y/x in the range
  • ? lt arctan y/x ?.

7
The math Functions
  • double cosh(double x)
  • Return cosh x.
  • double sinh(double x)
  • Return sinh x.
  • double tanh(double x)
  • Return tanh x.

8
The math Functions
  • double exp(double x)
  • Return ex (natural base e 2.71828...).
  • double log(double x)
  • Return ln x (natural base e 2.71828...).
  • double log10(double x)
  • Return log x (base 10).

9
The math Functions
  • double pow(double x, double y)
  • Get x raised to the y power.
  • double sqrt(double x)
  • Get the square root of x.

10
The math Functions
  • double ceil(double x)
  • Get the integer n such that n 1 lt x n
  • double floor(double x)
  • Get the integer n such that n x lt n 1.

11
Examples of Math Functions
  • FinancialPlanner.cpp
  • Surveyor1.cpp
  • Surveyor2.cpp

12
The ctype Library
  • The ctype library contains functions that
    facilitate the manipulation of characters.
  • Include ltcctypegt in the .cpp file in which the
    functions are used.
  • These functions return int because int was the
    old-style bool (0 is false, ? 0 is true).

13
The ctype Functions
  • int isalpha(int c)
  • Determine whether the specified character c is an
    uppercase or a lowercase letter.
  • int isdigit(int c)
  • Determine whether the specified character c is a
    digit.

14
The ctype Functions
  • int isupper(int c)
  • Determine whether the specified character c is an
    uppercase letter.
  • int islower(int c)
  • Determine whether the specified character c is a
    lowercase letter.

15
The ctype Functions
  • int tolower(int c)
  • Get the lowercase equivalent of the specified
    character c if c is an uppercase letter. The
    character c is returned if c is not an uppercse
    letter.
  • int toupper(int c)
  • Get the uppercase equivalent of the specified
    character c if c is a lowercase letter. The
    character c is returned if c is not a lowercase
    letter.

16
The ctype Functions
  • int isalnum(int c)
  • Determine whether the specified character c is an
    uppercase or a lowercase letter or a digit.
  • int ispunct(int c)
  • Determine whether the specified character c is a
    punctuation character.

17
The ctype Functions
  • int isspace(int c)
  • Determine whether the specified character c is
    white space (space, newline, tab, form feed).
  • int iscntrl(int c)
  • Determine whether the specified character c is a
    control character.

18
The ctype Functions
  • int isgraph(int c)
  • Determine whether the specified character c is a
    graphics character.
  • int isprint(int c)
  • Determine whether the specified character c is a
    printable character.

19
The ctype Functions
  • int isxdigit(int c)
  • Determine whether the specified character c is a
    hexadecimal digit (0 - 9, a - f, A - F).

20
Examples of ctype Functions
  • Validator.cpp
Write a Comment
User Comments (0)
About PowerShow.com