53h MT$FBDC convert floating point to string
Input A register - field width of output string.
B register - decimal places required.
X register - address of output buffer.
Output B register - length of the output string.
Description

Converts floating-point accumulator to numeric ascii text, decimal format. This is the format nnnn.nnn, ie. a decimal number with no exponent. If the number of significant digits after the decimal point is greater than the decimal places specified in B, the number is rounded off to B decimal places. Otherwise it is zero-filled on the right to make up the necessary decimal places.

Returns the output string (not zero-terminated) at the address given by X on entry, with the length of the string in B. X should be preserved before calling, as there is no pointer to the output string on exit.

Other floating point to string conversion utilities: MT$FBEX, MT$FBGN and MT$FBIN.

See also: technical manual > utility system services > floating point numbers

Example The following code will convert the value in the accumulator to a decimal format string with 5 decimal places in a field width of 16:
        LDX     #STRING_BUF
        LDD     #16*256 + 5     ;field width in A,
                                ;dec. places in B
        OS      MT$FBDC

    STRING_BUF:
        DS      16

If the accumulator contained e.g. 172.65, STRING_BUF will now contain the string "172.65000" and the B register will contain 9. The string will not be zero-terminated unless STRING_BUF is zero-filled before the routine is called.

Further examples of the output strings corresponding to various floating-point values follow:

  Accumulator   Width   Dec. Places     Output String

    0.0000004     20        4            0.0000
    0.00006       20        4            0.0001
    0             20        4            0.0000
    1234.5        20        4            1234.5000
    1234.5         8        4            Error 
                                           (Width too small)
    34E+10        20        4            340000000000.0000
    9E+20         60       14            Error
                                           (Too long for work buffer)
Errors 250 - output string too long for field width or greater than maximum work buffer length of 34 (NUM to STR Error)