Formatting Numerical Values



[1]
_ntoS(num {,iIntD} {,iDecD} {,sSign} {,#c} ) NumberToString
  Returns <strS> / <err>
  num Integer / Float / HexString to be formatted
  iIntD Integer. Desired length of the integer portion of the string (max value: 32) .
If iIntD is higher than the length of the generated integer portion, the resulting string will be prefixed with [intD -  string length] zeros. A lower setting (e.g. 0) will not truncate the result.
  iDecD Integer. Desired decimal precision of the string.
Max value 10 | Default value when num is a float 3 , 0 otherwise.
  sSign Symbol sign. If not set, no prefix will be added to non-negative values.
#s1: a '+' sign will be prefixed to positive values.
#s2: a '+' sign will be prefixed to positive values, and a space will be prefixed to the value of 0.
#s3: a '+' sign will be prefixed to all non-negative values, including zero.
  #c If used, a comma (',') separator will be used for every 3 digits of the integer portion of the value.
     
  Description Formats a numerical value to a string. The resulting string's code page will be the default CP (glbCP).
If the conversion fails, an<err> will be returned.
     
  Examples put _ntoS(48)
-- 48
put _ntoS(48, 5)
-- 00048
put _ntoS(48.0)
-- 48.000
put _ntoS(48.0, 0 , 2)
-- 48.00

put _ntoS(14, #s1)
-- +14
put _ntoS(0, #s1)
-- 0
put _ntoS(0, #s2)
--   0
put _ntoS(0, #s3)
-- +0

put _ntoS(0.98, #s1)
-- +0.980

put _ntoS(657.657, 8, 2, #c)
-- 00,000,657.66

put _ntoS("FF", 4)
-- 0255

put _ntoS(1000.98, 8, 2, #s1, #c)
-- +00,001,000.98
put _ntoS(1000.98, 8, 1, #s1, #c)
-- +00,001,001.0

put _ntoS(0.1223)
-- 0.122
put _ntoS(0.1223, 0) --see note below
-- .122
     
  Notes When iIntD is 0 and the value is higher than -1 and less than 1, but not zero, the integer part will be empty - the string will be starting with a dot ('.').