REAL Output: The E Descriptor

The Ew.d and Ew.dEe descriptors are for REAL output. The printed numbers will be in an exponential form. The general form of these descriptors are discussed below. There are two more forms, ESw.d and ENw.d, which will be discussed at the bottom of this page.

rEw.d     and     rEw.dEe

The meaning of r, w, d and e are:

Examples

In the following table, the WRITE statements use different E edit descriptors to print the value of 3.1415926. The WRITE statements are shown in the left and their corresponding output, all using 12 positions, are shown in the right.

Editor Descriptor ESw.d and ESw.dEe

Scientists write the exponential form in a slightly different way. This ES edit descriptor is for printing a real number in scientific form, which has a non-zero digit as the integral part. If the number is a zero, then all digits printed will be zero. The following shows the printed form:

If you understand the form of normalized number, you can just shift the decimal point to the right one position and decrease the exponent by one. The result is in scientific form.

For example, if the number is 34.5678, it has a normalized form 0.345678×102. Now shifting the decimal point to the right one position gives 3.45678×101. The following shows the output printed with ES12.3E3:

Editor Descriptor ENw.d and ENw.dEe

Engineers write the exponential form in yet another way. In an engineering form, the exponent is always a multiple of three, and the printed number always has no more than three and at least one non-zero digits. For example, suppose the given number is 1234.567. The integral part has four digits and the exponent is zero. To convert this number to an engineering form, the decimal point should be shifted to the left three positions. Thus, the given number has a new form 1.234567×103. Similarly, if the given number is 0.00001234567, shifting the decimal point to the right three positions gives 0.01234567×10-3. However, this is not yet in the engineering form, because the integral part is still zero. Therefore, we need to shift the decimal point to the right three positions again and this gives 12.34567×10-6. Now, the number is in engineering form.

The following shows the output of ENw.d and ENw.dEe. For ENw.d, it requires 4 positions for the exponent, d positions for the fractional part of the number, 3 positions for the integral part, one position for the decimal point, and one position for the possible sign. It requires at least d+9 positions and consequently for ENw.d, w must be larger than or equal to d+9. The same counting yields that for ENw.dEe, w must be larger than or equal to d+e+7 .