
Simply, you will get the same type of result if you put the same type of numbers. A formula with both real numbers always returns a real number.A formula with both integer and real numbers always returns a real number.A formula with only integer numbers always returns an integer number.Some arithmetic rules in Fortran are not intuitive because the type of value is strictly considered. You can use as many as operators in a formula such as 1+((5+4/2)**6)/2-8/4+2. Operatorīy default, the priority of operators is the same as the arithmetic rule ( ** > * and / > + and -), and the operators are evaluated from left to right. The operators are very similar to the one used in mathematics. Print some extremely huge (or tiny) integer literals, and see how big (small) values Fortran can hold.įortran has several operators for numeric values.The numeric and character literals can coexist in print.The print statement put a margin to the output of numeric literals.Fortran holds both integer and real numbers two are differentiated.This is useful to precisely display the numeric values. program numĮnd program num Avogadro constant= 6.02000017E+23 You can mix numeric and character literals in print. The default output has enough margin to show a number. Note that the output format depends on the type and the magnitude of value. The numeric literal can also be used in print. ) or exponential identifier ( e or E) in addition to the numbers and the sign, it is a real number. If the literal has only numbers and optionally a sign ( \(+\) or \(-\)), it is an integer.In Fortran, the type of number (integer vs. real) is strictly differentiated. Fortran supports integer numbers, real numbers with the decimal point or expressed as the exponential style, and complex numbers (which we do not deal with in this tutorial). A number is expressed as a numeric literal, which is simply a sequence of numbers with some symbols. Literals and simple computations Numeric and character literals Numbersįortran can do any simple arithmetic. As seen in this chapter, the default integer number in Fortran uses 4 bytes (32 bits) as a unit. 1-byte data can represent at least \(2^8=256\) different values. Most of the computers that we are using define 8 bits as the smallest unit in operation. The bit is a unit having one of the two values. So, in the binary system, \(1+1=10\) with a carry. There are 10 (from 0 to 9) decimal digits in the decimal system, and there are only two (0 or 1) in the binary system. Whereas people use the decimal system, a computer uses the binary system. Numerical expression Numerical expression
