'numberformat
'action: control how numbers are converted to strings
'use: change the format of numbers
'example: numberformat 3,0,0,0 : print 3.14159
' 'result: 3.142
'remarks: there are 6 parameters:
' 1 decimal places (0..16)
' 2 strip end zeros (0 or 1)
' 3 always use scientic notation E format (0 or 1)
' 4 suppress 0 before decimal point: 0.1 becomes .1 (0 or 1)
' 5 insert extra leading space for non-negative numbers (0 or 1)
' 6 width allocated before decimal point: (0..31)
' (inserting lead padding spaces)
'
' when no parameters are given, it reverts to the default settings:
' 16,1,0,0,0,0
' rounding is automatically performed before the decimal places are truncated.
cr=chr(13)+chr(10)
pr="Number Format Control Examples" cr
NumberFormat 'default
pr+=cr ">>" str 1234.5678
NumberFormat 16,1,1,0,0,0 'always use scientific notation
pr+=cr ">>" str -1234.5678
NumberFormat 08,0,0,0,0,0 '8 decimal places, leave end zeros
pr+=cr ">>" str -1234.5678
NumberFormat 16,1,0,0,1,0 'insert extra leading space for non-negative numbers
pr+=cr ">>" str 1234.5678
NumberFormat 2,1,0,0,1,10 'pad numbers 11 places before decimal point including '-' place
pr+=cr ">>" str -1234.5678
pr+=cr ">>" str 1234.5678
print pr
numberformat 'restore default seeting 16,1,0,0,0,0