help autofmt

-------------------------------------------------------------------------------

Title

autofmt -- automatic formating of a significant number of digits

Syntax

autofmt, input(string) dec(#) parse(string) strict]

Description

autofmt provides a fast and easy way to format decimals to a significant number of digits. It will handle leading or trailing zeros. It will go into exponential format when the number is too small or too large.

The default setting is "plus-1" significant digits, meaning it will add one more digit if there is a digit to the left of decimals, i.e. 1.001 would be treated as 3-plus-1 digits. Use strict if you don't want this.

Whole numbers are left alone, as is the general practice, unless it is placed into exponential format.

Options

+------+ ----+ Main +-------------------------------------------------------------

input(#) a number to be formatted, can be multiple numbers.

dec(#) a number of significant digits. The default is dec(3).

parse(string) parse character. Only one accepted. The default is parse(" ").

strict strict number of significant digits. Don't do plus-1 number of digits.

Examples

. autofmt, input(-1.367456 -0.0000925 -0.5623 -13.5678) dec(2) . ret list

scalars: r(deci4) = 1 r(deci3) = 2 r(deci2) = 6 r(deci1) = 2

macros: r(output4) : "-13.6" r(input4) : "-13.5678" r(fmt4) : "1f" r(output3) : "-0.56" r(input3) : "-0.5623" r(fmt3) : "2f" r(output2) : "-0.000092" r(input2) : "-0.0000925" r(fmt2) : "6f" r(output1) : "-1.37" r(input1) : "-1.367456" r(fmt1) : "2f"

Remarks

Based on codes from -outreg2-.

Author

Roy Wada roywada@hotmail.com