Task

Express a number in decimal as a fixed-length string with leading zeros.



For example, the number   7.125   could be expressed as   00007.125.




      PRINT FNformat(PI, 9, 3)
      PRINT FNformat(-PI, 9, 3)
      END
 
      DEF FNformat(n, sl%, dp%)
      LOCAL @%
      @% = &1020000 OR dp% << 8
      IF n >= 0 THEN
        = RIGHT$(STRING$(sl%,"0") + STR$(n), sl%)
      ENDIF
      = "-" + RIGHT$(STRING$(sl%,"0") + STR$(-n), sl%-1)