AccessMyLibrary provides FREE access to over 30 million articles from top publications available through your library.

A treatment of computational precision, number representation, and large integers in an introductory Fortran course.

Journal of Computers in Mathematics and Science Teaching

| September 22, 2006 | Richardson, William H., Jr. | COPYRIGHT 2006 Association for the Advancement of Computing in Education (AACE). This material is published under license from the publisher through the Gale Group, Farmington Hills, Michigan.  All inquiries regarding rights should be directed to the Gale Group. (Hide copyright information)Copyright

Computational precision is sometimes given short shrift in a first programming course. Treating this topic requires discussing integer and floating-point number representations and inaccuracies that may result from their use. An example of a moderately simple programming problem from elementary statistics was examined. It forced students to confront problems associated with number representations and investigate appropriate ways to circumvent them. In the example, integers were represented using two's complement form, and floating-point numbers according to the Institute of Electrical and Electronics Engineers (IEEE) standard 754, both using 32 bits. Floating-point number representation (64-bit) was necessary to achieve results accurate to two decimal positions. Finally, Fortran 90/95 subprograms were written to implement arbitrarily precise operations with large integers. Students in an introductory course can write subprograms for addition and subtraction of large integers. More sophisticated subprograms that depend on the fast Fourier transform were written to perform multiplication and division of large integers. These subprograms are more suited to an advanced programming or numerical analysis course. The subprograms written to perform large-integer operations were used to determine exact solutions for the statistical problem.

**********

Programming in Fortran 90/95 is taught predominately to math and science majors at Francis Marion University, but some nonscience majors enroll in the course to satisfy a general education requirement in computer science. As a teacher of Fortran, I am routinely asked why our mathematics department "still teaches Fortran." Yet Fortran is the most widely used scientific programming language (Decyk, Norton, & Szymanski, 1995). Fortran 90/95, the current incarnation of the first scientific programming language, is the language of choice for scientific computation. Many of the features of Fortran 90/95 that give it this distinction are not generally discussed in an introductory course. However, they become important in sophisticated number-crunching applications encountered in scientific research. While C/C++ may often be perceived as the language with panache, Fortran 90/95 compiled code commonly executes an order of magnitude faster. Fortran 90/95 alone provides standardized language support for parallel computing (Prentice, 1995). A vast collection of Fortran programming is in use because Fortran is the oldest scientific language. Recoding to another language is economically impractical and typically resisted (Burley, 1998). See the document by Burley, the position taken by Cambridge University's High Performance Computing Facility (2000), and the letter by Prentice for more detailed discussions of Fortran's strengths in the area of scientific computing.

For students enrolled in an introductory programming course the demands of learning language syntax and mastering the art of progressing from a stated problem to pseudocode, and on to a well-written computer program often leave little classroom time for issues like internal representation of numbers and the impact that representation has on numerical precision. This is particularly true when most students in the class have no prior programming experience. Elements of the Institute of Electrical and Electronics Engineers (IEEE) 754-1985 standard, which govern binary floating-point arithmetic on an overwhelming majority of processors, are often relegated to more advanced programming or computer science courses.

Yet such issues can have a profound effect, which can be seen in an introductory setting. Consider the following adaptation of an example from a Fortran text (Nyhoff & Leestma, 1997, pp. 738-739). The following line of Fortran 90/95 code computes the square of the binomial A+B, subtracts all terms except [A.sup.2], and then divides by [A.sup.2]: C = ((A+B)**2-2*A*B-B**2)/A**2. For nonzero values of A, C=1. Variables A, B, and C have been typed REAL (Fortran floating-point, single precision). Table 1 shows the computed value C for different values of A, when B has the value 1000.0. Results were determined using a desktop PC (Windows 98) with an AMD Athlon processor (Digital Visual Fortran compiler) and an HP Alpha 2100 machine with the Open VMS operating system and associated compiler.

The inevitability of errors such as those shown in Table 1 has been a topic of study since the early days of computing. Interval arithmetic is one response to the problem. See the article by Hayes (2003) for an interesting introduction to this field. Using interval arithmetic, real numbers are replaced with intervals on which operations are performed. For example, let [a,b] represent the interval of real numbers between a and b, inclusive. Suppose x and y are not known exactly and that 1 [less than or equal to] x [less than or equal to] 3 and 5 [less than or equal to] y [less than or equal to] 8. The sum x + y can be expressed using interval addition as [1,3] + [5,8] = [6,11]. This interval addition replaces the conventional sum x + y where x and y represent known real numbers. A lower bound and an upper bound for x + y are 6 and 11, respectively. Of course, the sum x + y may be inaccurate, but at least the error is bounded and not hidden from view. Unfortunately, other interval operations are not so simple. Although much work has been done, support for interval algorithms in computing hardware has not been realized. Hardware support (as opposed to exclusive software support) for floating-point arithmetic became widely available only after the IEEE published floating-point format standards. Although drafts of standards for interval arithmetic exist, as yet none has been adopted by any standard-setting body (Hayes, 2003).

Unlike the obvious errors in computation like those shown in Table 1, some computational inconsistencies are subtler. One example is the lack of uniformity across different computing platforms when the IEEE standard is followed--at least nominally. That is, some components of the IEEE 754 standard may not be followed in a particular computing environment because of the processor or compiler (or both) in use. For an example, consider the internal representation of extremely small floating-point numbers on various platforms. Called denormalized or subnormal numbers in the IEEE standard, some processors allow users to opt out of using these floating-point numbers because of the associated degradation in performance.

Related articles from newspapers, magazines, journals, and more
FORTRAN rebirth: FORTRAN gets a facelift for the '90s. (includes related...
Magazine article from: Computer Shopper Nicolaisen, Nancy June 1, 1995 700+ words
...language will be called in the year 2,000: FORTRAN." And so it is. This oracle, we must...doppelganger, COBOL, the sheer magnitude of FORTRAN's historical presence almost guaranteed...models are written at least partly in FORTRAN. The FORTRAN code base probably includes...
Fortran's fold sends creditors to court.
Magazine article from: Crain's Cleveland Business Cornell, Ryan June 17, 2002 700+ words
...funds they can from the now-defunct Fortran Printing Inc. of Cleveland, an offset...than $2.3 million in unpaid debts. Fortran, which had about 100 employees before...In separate complaints filed against Fortran since March, three other creditors...
IMSL Fortran Numerical Library v5.0 Now Available with IBM XL Fortran Advanced...
Press release article from: Business Wire November 10, 2004 700+ words
...Libraries Now Bundled with IBM's XL Fortran Advanced Edition V8.1 on Apple's Latest...announced that Visual Numerics' IMSL(TM) Fortran Numerical Library version 5.0 will be...performance and award-winning IBM XL Fortran Advanced Edition compiler Version 8...
Fortran
Encyclopedia entry from: Gale Encyclopedia of E-Commerce January 1, 2002 700+ words
FORTRAN FORTRAN (FORmula TRANslating) is a programming language historically used in...to a primary, numeric machine language consisting of zeros and ones. FORTRAN was developed by John Backus at IBM's world headquarters in 1954, and...
LS Fortran 1.1.(Fortner Research's compiler) (Software...
Magazine article from: Macworld Seiter, Charles February 1, 1996 700+ words
...cais.com). LIST PRICE: $695. FORTRAN is still the language of choice in broad...and aerospace design. Compilers like LS FORTRAN from Fortner Research (formerly Language...engineering and quantum chemistry as well. FORTRAN customers tend to be concentrated near...
Pro FORTRAN 5.0. (Absoft) (Software Review)(Evaluation)(Brief Article)
Magazine article from: Macworld Seiter, Charles July 1, 1997 700+ words
...real world, older languages like COBOL and FORTRAN are still doing much of the day-to-day...numeric calculation, for example, the ancient FORTRAN language in one of its newer forms--FORTRAN 77 or FORTRAN 90--is still grinding away...
Here comes Fortran 2003.(Data Management & Analysis)(Interview)
Magazine article from: R & D Studt, Tim February 1, 2004 700+ words
...a participant in both U.S. and international Fortran standards committees for 15 years. Q: When will Fortran 2003 be available to researchers ? A: Actually, some may find the name "Fortran 2003" to be a bit of a misnomer, as the new standard...
Absoft Announces Pro Fortran 9.2 64-bit Fortran Compiler for Mac OS X v10.4...
Press release article from: PR Newswire April 29, 2005 700+ words
...Corporation, the leading provider of Fortran tools for the Mac platform, today announced their Pro Fortran v9.2 Compiler Suite for Apple's new...v10.4 "Tiger" operating system. Pro Fortran v9.2 provides full support for Apple...
For more facts and information, see all results
©2009 Gale, a part of Cengage Learning. All rights reserved.
About us | FAQs | Contact us | Privacy policy | Terms and conditions
Other Gale sites: Encyclopedia.com | HighBeam Research | Acquire Content | Books & Authors | Goliath | MovieRetriever | Smart QandA