Appendix B Math Class - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

Appendix B Math Class

Description:

A decimal number with 28 digits, or fewer, and 28 decimal places, or fewer, will ... Mutable. Has property Length. Has get, set indexer. Methods: ... – PowerPoint PPT presentation

Number of Views:33
Avg rating:3.0/5.0
Slides: 13
Provided by: jimfa
Category:
Tags: appendix | class | math | mutable

less

Transcript and Presenter's Notes

Title: Appendix B Math Class


1
Appendix B Math Class
  • Jim Fawcett
  • CSE791 Advanced Windows Programming
  • Summer 2002

2
Numeric Types C/.Net
3
Decimal
  • A decimal number with 28 digits, or fewer, and 28
    decimal places, or fewer, will be stored
    exactly. x,xxx,xxx,xxx,xxx,xxx,xxx,xxx,xxx,xxx
  • Decimals are used mostly to represent money
    without roundoff errors.

4
Floating Point
  • The range of valid Floats is -3.402823 x 1038
    lt float lt 3.402823 x 1038
  • Smallest float greater than zero is 1.401298 x
    10-45
  • Range of valid doubles is -1.79769313486232 x
    10308 lt double lt 1.79769313486232 x
    10308
  • Smallest double greater than zero is
    4.94065645841247 x 10-324

5
Invalid Floating Point Numbers
  • Operations on floats and doubles never throw
    exceptions.
  • Dividing by zero results in infinity or
    infinity, depending on the sign of the
    numerator.
  • Dividing zero by zero or infinity by infinity
    results in NAN, not-a-number, as does subtracting
    infinity from infinity.

6
Math Class
  • The math class consists of all static methods and
    two constant fields PI 3.14159265358979 E
    2.71828182845905
  • Most of the methods are defined only for
    doubles.
  • Max and Min are defined for all numeric types
  • Sign and Abs are defined for float, double,
    decimal, and all signed integer types

7
Modulus Operator, Methods
  • Modulus operator in C result dividend
    divisorreturns the remainder after division,
    and is defined for all numeric types.
  • Power double result Power(double base, double
    power)
  • Exponential double result Exp(double power)
  • Square Root double result Sqrt(double value)

8
Logarithms
  • Log to base 10 double Log10(double value)
  • Log to base e double Log(double value)
  • Integer base double Log(double value, double
    base)

9
Trigonometric Methods
  • double sin(double angle)
  • double Cos(double angle)
  • double Tan(double angle)
  • double Asin(double value)
  • double Acos(double value)
  • double Atan(double value)
  • double Atan2(double y, double x)
  • double Sinh(double angle)
  • double Cosh(double angle)
  • double Tanh(double angle)

10
Appendix C String Theory
  • string class
  • Immutable
  • Mutating functions return a new string
  • Has read-only indexer access to individual chars
  • Has Length property
  • Methods returning a new string
  • BinarySearch, CompareTo, Concat, Copy, Format,
    IndexOf (substring), Insert, LastIndexOf,
    PadLeft, PadRight, Remove, Replace, Sort,
    ToLower, ToUpper, Trim, TrimEnd, TrimStart
  • Operators , , , , !,
  • Assignment points to new string, loses old
    reference.

11
C Control Characters
12
StringBuilder
  • StringBuilder Class
  • Defined in System.Text
  • Mutable
  • Has property Length
  • Has get, set indexer
  • Methods
  • Append, AppendFormat, Insert, Remove, Replace
  • Operators
  • , !,
Write a Comment
User Comments (0)
About PowerShow.com