Download Introduction to Programming in Turing First Edition

Transcript
Appendix B : Predefined Subprograms
425
fractionWidth parameter is the non-negative number of
fractional digits to be displayed. The displayed value is
rounded to the nearest decimal equivalent with this accuracy,
with ties rounded to the next larger value. The exponentWidth
parameter must be non-negative and gives the number of
exponent digits to be displayed. If exponentWidth is not large
enough to represent the exponent, more space is used as
needed. The string returned by erealstr is of the form:
{blank}[]digit,{digit}e sign digit {digit}
where ñsignî is a plus or minus sign. The leftmost digit is nonzero, unless all the digits are zeroes.
frealstr (r : real, width, fractionWidth: int): string
Returns a string approximating r, padded on the left with
blanks if necessary to a length of width. The number of digits
of fraction to be displayed is given by fractionWidth; for
example, frealstr(2.5e1,5,1) = "b25.0" where b represents a
blank. The width must be non-negative. If the width parameter
is not large enough to represent the value of r, it is implicitly
increased as needed. The fractionWidth must be nonnegative. The displayed value is rounded to the nearest
decimal equivalent with this accuracy, with ties rounded to the
next larger value. The result string is of the form:
{blank} [] digit{digit}.{digit}
If the leftmost digit is zero, then it is the only digit to the left of
the decimal point.
realstr (r : real, width : int): string
Returns a string approximating r, padded on the left with
blanks if necessary to a length of width, for example,
realstr(2.5e1,4) = "bb25" where b represents blank. The width
parameter must be non-negative. If the width parameter is not
large enough to represent the value of r, it is implicitly
increased as needed. The displayed value is rounded to the
nearest decimal equivalent with this accuracy, with ties
rounded to the next larger value. The string realstr(r, width) is
the same as the string frealstr(r, width, defaultfw) when r = 0
or when 1e –3 ? abs(r) < 1e 6, otherwise the same as