18.10.2014 Views

SIMSCRIPT II.5 Programming Language

SIMSCRIPT II.5 Programming Language

SIMSCRIPT II.5 Programming Language

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Programming</strong> <strong>Language</strong> Concepts<br />

numbers are printed unsigned, while negative numbers have the sign printed to the left of the highest-order<br />

digit. Leading zeros are suppressed.<br />

3.4.2.2 D (Decimal) Descriptor<br />

A descriptor of the form n D(a,b) is used for converting numbers from internal to external decimal<br />

representation, and vice versa. The a field specifies the number of characters in the data field, including<br />

the sign and decimal points. The b field specifies the number of digits to the right of the<br />

decimal point; and the optional n field specifies the number of consecutive values of the format.<br />

When used for input, the D format accepts numbers typed with or without decimal points. If a decimal<br />

point is omitted, one is implied before the first digit in the b field. When a decimal point is<br />

present, it overrides the location specified by b. Very large and very small numbers can be input in<br />

scientific notation, for when used for input the D and E formats are equivalent.<br />

Used in output statements, D formats describe the precision in which decimal numbers are displayed.<br />

Numbers that cannot be printed exactly in the specified format are rounded. Every number<br />

output by a D format is printed in a field of a columns: the first column is used for the sign, the next<br />

a-b-2 columns are for digits, the next column is for the decimal point, and the remaining b columns<br />

are for digits. The sign is printed if a number is negative; otherwise it remains blank. If the integer<br />

part of a negative decimal number does not require all the a-b-2 positions allotted to it, the sign is<br />

shifted to the right, next to the high-order digit. Leading zeros are suppressed. If a number has trailing<br />

zeros, as in the number 10.0, the trailing zeros are printed. Trailing zeros are not printed for a<br />

value of exactly zero.<br />

3.4.2.3 E (Scientific) Descriptor<br />

Extremely large and extremely small numbers, and numbers that vary widely in scale, can be read<br />

and written in a constant field width by using an E format. This format is similar to the D format<br />

in that it specifies a field width and a decimal point position by the numbers a and b in the form n<br />

E(a,b), but it differs from the D format in having a scale factor field. The scale factor field appears<br />

to the right of a decimal number and indicates the necessary number of places right or left that the<br />

decimal point must be moved to convert the scaled number to its proper form.<br />

The E format is thus equivalent to the D format, plus a scale factor. Numbers read under E format<br />

control are of the general form:<br />

±XXX.XXXE±XX<br />

although some latitude is allowed in writing the scale factor. A positive scale factor, such as E+02<br />

or E 7, raises the value of a printed number; 24.795E-04 represents an internally stored value of<br />

.0024795.<br />

The E format can be used for both input and output. When used for output, it aligns numbers according<br />

to the format specification and prints a scale factor indicating the true value of the printed<br />

number. All E formatted numbers are a print positions wide, with the first a-4 positions used for<br />

107

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!