PROGRAM Largest ! ------------------------------------------------------------------------------ ! ! Copyright 2006 Matthew Norton ! ! ------------------------------------------------------------------------------ ! This program is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ! ! NOTE: This is in FORTRAN 90 and you will need a FORTRAN 90 complier to run ! this code ! ------------------------------------------------------------------------------ ! ! This program calculates the largest number that your computer can represent ! using floating point notation ! ! ------------------------------------------------------------------------------ ! ! PROGRAM HISTORY ! ! AUTHOR: Matthew S. Norton ! CREATION DATE: January 25, 2007 ! ! ------------------------------------------------------------------------------ REAL*8 :: Num1, Num2 INTEGER :: I Num1 = 1. Num2 = 2 I = 1 OPEN (UNIT = 20, FILE = "Large.txt") DO IF (I == 1050) THEN EXIT END IF IF (Num2 / Num1 /= 2.) THEN WRITE (*,*) "Largest #", Num1, Num2 WRITE (20,'(1X, A10, 1X, E18.10E4, 2X, E18.10E4)') "Largest #", Num1, Num2 EXIT END IF Num1 = Num1 * 2. Num2 = Num2 * 2. WRITE (20, '(1X, I1 1X, A7, 1X, E18.10E4, 1X, A7, E18.10E4)') I, "Num1 =", Num1, "Num2 = ", Num2 PRINT *, I, "Num1 = ", Num1, "Num2 = ", Num2 I = I + 1 END DO END PROGRAM