Chapter 11 Additional Intrinsic Data Types Dr. Ali Can Takinacı İstanbul Technical University Faculty of Naval Architecture and Ocean Engineering İstanbul.

Slides:



Advertisements
Similar presentations
Methods Java 5.1 A quick overview of methods
Advertisements

Arrays.
Exponential Functions Logarithmic Functions
Types and Arithmetic Operators
The Assembly Language Level
ECE 3336 Introduction to Circuits & Electronics
Chapter 5 Basic I/O Concepts Dr. Ali Can Takinacı İstanbul Technical University Faculty of Naval Architecture and Ocean Engineering İstanbul - Turkey Tel:
1 ICS 101 – LAB 2 Arithmetic Operations I Putu Danu Raharja kfupm.edu.sa Information & Computer Science Department CCSE - King Fahd University.
Data types, declarations, and expressions in Java.
1 Chapter 9 - Formatted Input/Output Outline 9.1Introduction 9.2Streams 9.3Formatting Output with printf 9.4Printing Integers 9.5Printing Floating-Point.
Chapter 8 Introduction to Arrays Part II Dr. Ali Can Takinacı İstanbul Technical University Faculty of Naval Architecture and Ocean Engineering İstanbul.
Chapter 10 Additional Features of Arrays Dr. Ali Can Takinacı İstanbul Technical University Faculty of Naval Architecture and Ocean Engineering İstanbul.
Chapter 3 Program Design and Branching Structures Dr. Ali Can Takinacı İstanbul Technical University Faculty of Naval Architecture and Ocean Engineering.
COMPSCI 125 Spring 2005 ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 3: Numeric Data *Variables *Numeric data.
Chapter 7 Introduction to Arrays Part I Dr. Ali Can Takinacı İstanbul Technical University Faculty of Naval Architecture and Ocean Engineering İstanbul.
Chapter 2 Basic Elements of Fortan
Chapter 4 Loops and Character Manipulation Dr. Ali Can Takinacı İstanbul Technical University Faculty of Naval Architecture and Ocean Engineering İstanbul.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 9 - Formatted Input/Output Outline 9.1Introduction.
Chapter 3 Numerical Data. Topics Variables Numeric data types Assignment Expressions.
JavaScript, Third Edition
Chapter 9 Introduction to Procedures Dr. Ali Can Takinacı İstanbul Technical University Faculty of Naval Architecture and Ocean Engineering İstanbul -
Chapter 6 AN INTRODUCTION TO FILES AND FILE PROCESSING Dr. Ali Can Takinacı İstanbul Technical University Faculty of Naval Architecture and Ocean Engineering.
Introduction to Array The fundamental unit of data in any MATLAB program is the array. 1. An array is a collection of data values organized into rows and.
In this section we will introduce a new concept which is the logarithm
Basic Elements of C++ Chapter 2.
Chapter 3 Computing with Numbers
Fortran- Subprograms Chapters 6, 7 in your Fortran book.
Python Programming, 2/e1 Python Programming: An Introduction to Computer Science Chapter 3 Computing with Numbers.
Copyright © Cengage Learning. All rights reserved. CHAPTER 11 ANALYSIS OF ALGORITHM EFFICIENCY ANALYSIS OF ALGORITHM EFFICIENCY.
Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission.
Expressions and Interactivity Chapter 3. 2 The cin Object Standard input object Like cout, requires iostream file Used to read input from keyboard Often.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Streams Streams –Sequences of characters organized.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 9 - Formatted Input/Output Outline 9.1Introduction.
Chapter 9 Formatted Input/Output. Objectives In this chapter, you will learn: –To understand input and output streams. –To be able to use all print formatting.
Fortran 1- Basics Chapters 1-2 in your Fortran book.
Chapter 9 Formatted Input/Output Associate Prof. Yuh-Shyan Chen Dept. of Computer Science and Information Engineering National Chung-Cheng University.
© The McGraw-Hill Companies, 2006 Chapter 4 Implementing methods.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
COMPE 111 Introduction to Computer Engineering Programming in Python Atılım University
CNG 140 C Programming Lecture Notes 2 Processing and Interactive Input Spring 2007.
A First Book of ANSI C Fourth Edition Chapter 3 Processing and Interactive Input.
Chapter 06 (Part I) Functions and an Introduction to Recursion.
What is an Array? An array is a collection of variables. Arrays have three important properties: –group of related items(for example, temperature for.
Summary of what we learned yesterday Basics of C++ Format of a program Syntax of literals, keywords, symbols, variables Simple data types and arithmetic.
Slide 4-1 Copyright © 2005 Pearson Education, Inc.
Chapter 8: Arrays and Functions Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
COMPUTER PROGRAMMING. Functions’ review What is a function? A function is a group of statements that is executed when it is called from some point of.
Other data types. Standard type sizes b Most machines store integers and reals in 4 bytes (32 bits) b Integers run from -2,147,483,648 to 2,147,483,647.
CONSTANTS Constants are also known as literals in C. Constants are quantities whose values do not change during program execution. There are two types.
Chapter 6 Mathematical Operations. 6.1 Mathematical Expressions In mathematics this expression is valid 0 = -4y + 5 It is invalid in programming Left.
Supervisor Ebtsam AbdelHakam Department of Computer Science Najran University 24/2/2014 Ebtsam Abdelhakam 1.
Chapter 3 Arithmatic Operations 3.1 Operators An operator is a symbol or world that represents some operation that is performed on one or more data values.
Lecture III Start programming in Fortran Yi Lin Jan 11, 2007.
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 2A Reading, Processing and Displaying Data (Concepts)
CSI 3125, Preliminaries, page 1 Data Type, Variables.
Converting between log form and exponential form.
Chapter 3 Numerical Data. Objectives After you have read and studied this chapter, you should be able to Select proper types for numerical data. Write.
COMPUTER PROGRAMMING. Array C++ provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same type. An.
1 C Syntax and Semantics Dr. Sherif Mohamed Tawfik Lecture Two.
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
Chapter INTRODUCTION Data Types and Arithmetic Calculations.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
Introduction to the C Language
Basic Elements of C++.
Basic Elements of C++ Chapter 2.
Introduction to the C Language
Copyright © Cengage Learning. All rights reserved.
Computing in COBOL: The Arithmetic Verbs and Intrinsic Functions
Presentation transcript:

Chapter 11 Additional Intrinsic Data Types Dr. Ali Can Takinacı İstanbul Technical University Faculty of Naval Architecture and Ocean Engineering İstanbul - Turkey Tel: +90 ( ) Fax: +90 ( )

Additional Intrinsic Data Types ALTERNATIVE KINDS OF THE REAL DATA TYPE For traditional reasons, the shorter version of the REAL data type on any particular computer is known as single precision, and the longer version of the REA L data type on any particular computer is known as double precision. On most computers, a single-precision real value is stored in 32 bits, and a double-precision real value is stored in 64 bits. However, some 64-bit processors use 64 bits for single precision and 128 bits for double precision. © 2010, Dr. ALİ CAN TAKİNACI Slide No: 2

Additional Features of Procedures Kinds of REAL Constants and Variables Since Fortran compilers have at least two different kinds of real variables, there must be some way to declare which of the types we want to use in a particular problem. This is done by using a kind type parameter. Single-precision reals and double-precision reals are different kinds of the REA L data type, each with its own unique kind number. In addition to the previous examples, a double-precision constant in exponential notation can be declared by using a D instead of an E to declare the exponent of the constant. For example, © 2010, Dr. ALİ CAN TAKİNACI Slide No: 3

Additional Features of Procedures Example: Program in Silverfrost Gives the output screen © 2010, Dr. ALİ CAN TAKİNACI Slide No: 4

Additional Features of Procedures Determining the KIND of a Variable Fortran 95 includes an intrinsic function KIND, which returns the kind number of a given constant or variable. This function can be used to determine the kind numbers in use by your compiler. © 2010, Dr. ALİ CAN TAKİNACI Slide No: 5

Additional Features of Procedures THE COMPLEX DATA TYPE Complex numbers occur in many problems in science and engineering. For example, complex numbers are used in electrical engineering to represent alternating current voltages, currents, and impedances. The differential equations that describe the behavior of most electrical and mechanical systems also give rise to complex numbers. Because they are so ubiquitous, it is impossible to work as an engineer without a good understanding of the use and manipulation of complex numbers. © 2010, Dr. ALİ CAN TAKİNACI Slide No: 6

Additional Features of Procedures © 2010, Dr. ALİ CAN TAKİNACI Slide No: 7

Additional Features of Procedures © 2010, Dr. ALİ CAN TAKİNACI Slide No: 8

Additional Features of Procedures Complex Constants and Variables A complex constant consists of two numeric constants separated by commas and enclosed in parentheses. The first constant is the real part of the complex number, and the second constant is the imaginary part of the complex number. For example, the following complex constants are equivalent to the complex numbers shown next to them: © 2010, Dr. ALİ CAN TAKİNACI Slide No: 9

Additional Features of Procedures A complex variable is declared by using a COMPLEX type declaration statement. The form of this statement is The kind of the complex variable is optional; if it is left out the default kind will be used. For example, the following statement declares a 256 element complex array. Remember that we are actually allocating 512 default-length values, since two real values are required for each complex number. © 2010, Dr. ALİ CAN TAKİNACI Slide No: 10

Additional Features of Procedures Initializing Complex Variables Like other variables, complex variables may be initialized by assignment statements, in type declaration statements, or by READ statements. © 2010, Dr. ALİ CAN TAKİNACI Slide No: 11

Additional Features of Procedures Using Complex Numbers with Relational Operators It is possible to compare two complex numbers with the == relational operator to see if they are equal to each other, and to compare them with the /= operator to see if they are not equal to each other. However, they cannot be compared with the >, =, or <= operators. The reason for this is that complex numbers consist of two separate parts. Suppose that we have two complex numbers c 1 = a 1 + b 1 i and c 2 = a 2 + b 2 i, with a 1 > a 2 and b 1 < b 2. How can we possibly say which of these numbers is larger? © 2010, Dr. ALİ CAN TAKİNACI Slide No: 12

Additional Features of Procedures COMPLEX Intrinsic Functions 1. Type conversion functions. These functions convert data to and from the complex data type. Function CMPLX(a, b) is a generic function that converts real or integer numbers a and b into a complex number whose real part has value a and whose imaginary part has value b. Functions REAL( ) and INT( ) convert the real part of a complex number into the corresponding real or integer data type, and throwaway the imaginary part of the complex number. Function AIMAG( ) converts the imaginary part of a complex number into a real number. © 2010, Dr. ALİ CAN TAKİNACI Slide No: 13

Additional Features of Procedures 2. Absolute value function. This function calculates the absolute value of a number. Function CABS(c) is a specific function that calculates the absolute value of a complex number, using the equation 3. Mathematical functions. These functions include exponential functions, logarithms, trigonometric functions, and square roots. The generic functions SIN, COS, LOG10, SQRT, etc. will work as well with complex data as they will with real data. © 2010, Dr. ALİ CAN TAKİNACI Slide No: 14