lecture07-feb4 - Announcements Lecture 7 Assignment 2 out,...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Announcements Lecture 7 –T ip : #include <stdlib.h> . . . system (“cls”); • Read Chapters 7 (7.3*) now, 8 for next week • Exam 1 – Friday, Feb. 20 th (in class) • Topics - details on basic data types (ch.7) – More on numerics char data type – Type conversions – Type casting (explicit) 2 Why is Data Typing Important? Safety - prevents meaningless or invalid code ("Hello World" / 3) Optimization - known sizes can support compiler optimizations Documentation - shows the intended data types of the programmer Abstraction - can build higher level types from lower level types (not really supported in C) 3 You have seen the numeric types int main(void) { int i, j; int numDays; float speed; double distance; scanf(“%d%f%lf”,&numDays, &speed, &distance); numDays = distance / speed; printf(“Speed = %10.3f Distance = %10.3f Time = %-7d”, speed, distance, numDays); return 0; } 4 <limits.h> #define SHRT_MIN (-32768) /* minimum (signed) short value */ #define SHRT_MAX 32767 /* maximum (signed) short value */ #define USHRT_MAX 0xffff /* maximum unsigned short value */ #define INT_MIN (-2147483647 - 1) /* minimum (signed) int value */ #define INT_MAX 2147483647 /* maximum (signed) int value */ #define UINT_MAX 0xffffffff /* maximum unsigned int value */ #define LONG_MIN (-2147483647L - 1) /* minimum (signed) long value */ #define LONG_MAX 2147483647L /* maximum (signed) long value */ #define ULONG_MAX 0xffffffffUL /* maximum unsigned long value */ #define LLONG_MAX 9223372036854775807i64 /* maximum signed long long int value */ #define LLONG_MIN (-9223372036854775807i64 - 1) /* minimum signed long long int value */ #define ULLONG_MAX 0xffffffffffffffffui64 /* maximum unsigned long long int value */ Preprocessor identifiers (macros) for the minimum and maximum values that can be stored for various integer data types - you can use them in your programs 5 <float.h> #define DBL_DIG 15 /* # of decimal digits of precision */ #define DBL_EPSILON 2.2204460492503131e-016 /* smal est such that 1.0+DBL_EPSILON != 1.0 */ #define DBL_MANT_DIG 53 /* # of bits in mantissa */ #define DBL_MAX 1.7976931348623158e+308 /* max value */ #define DBL_MAX_10_EXP 308 /* max decimal exponent */ #define DBL_MAX_EXP 1024 /* max binary exponent */ #define DBL_MIN 2.2250738585072014e-308 /* min positive value */ #define DBL_MIN_10_EXP (-307) /* min decimal exponent */ #define DBL_MIN_EXP (-1021) /* min binary exponent */ #define _DBL_RADIX 2 /* exponent radix */ #define _DBL_ROUNDS 1 /* addition rounding: near */ #define FLT_DIG 6 /* # of decimal digits of precision */ #define FLT_EPSILON 1.192092896e-07F /* smal est such that 1.0+FLT_EPSILON != 1.0 */ #define FLT_GUARD 0 #define FLT_MANT_DIG 24 /* # of bits in mantissa */ #define FLT_MAX 3.402823466e+38F /* max value */ #define FLT_MAX_10_EXP 38 /* max decimal exponent */ #define FLT_MAX_EXP 128 /* max binary exponent */ #define FLT_MIN
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

lecture07-feb4 - Announcements Lecture 7 Assignment 2 out,...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online