RosettaCodeData/Task/Formatted-numeric-output/BBC-BASIC/formatted-numeric-output.bbc

12 lines
293 B
Text
Raw Permalink Normal View History

2013-04-10 21:29:02 -07:00
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)