# FORMAT$()

Compatible with:
DOS Maximite CMM MM150 MM170 MM+ MMX Picromite ArmiteL4 Armite F4 ArmiteH7 Picomite CMM2

Syntax:
FORMAT$( nbr [, fmt$] )

Description:
Will return a string representing ‘nbr’ formatted according to the specifications in the string ‘fmt$’.
The format specification starts with a % character and ends with a letter.
Anything outside of this construct is copied to the output as is.
The structure of a format specification is:
% [flags] [width] [.precision] type
Where ‘flags’ can be:
- Left justify the value within a given field width 0 Use 0 for the pad character instead of space
+ Forces the + sign to be shown for positive numbers space Causes a positive value to display a space for the sign. Negative
values still show the – sign
‘width’ is the minimum number of characters to output, less than this the number will be padded, more than this the width will be expanded.
‘precision’ specifies the number of fraction digits to generate with an e, or f type or the maximum number of significant digits to generate with a g type.
If specified, the precision must be preceded by a dot (.).
‘type’ can be one of:
g Automatically format the number for the best presentation.
f Format the number with the decimal point and following digits
e Format the number in exponential format
If uppercase G or F is used the exponential output will use an uppercase E.
If the format specification is not specified “%g” is assumed.
Examples:
format$(45) will return 45
format$(45, “%g”) will return 45
format$(24.1, “%g”) will return 24.1
format$(24.1,”%f”) will return 24.100000
format$(24.1, “%e”) will return 2.410000e+01
format$(24.1,"%09.3f") will return 00024.100
format$(24.1,"%+.3f") will return +24.100
format$(24.1,"**%-9.3f**") will return **24.100 **

For an alternative used by the micromites, see STR$()

Last edited: 29 September, 2020