Acorn Computers BBC Micro Model B w/8271 — Acorn BBC Micro Model B w/8271 User Guide Manual PDF

60 Altering the width of the field and the way in which numbers are printed It is often useful to be able to specify the width of the field when printing columns of figures or words and also to be able to specify the number of decimal places to which numbers will be printed. On the BBC Microcomputer this can be done by setting a special ‘variable’ (called @ %) in a particular way. For the moment this must be treated as a bit of ‘magic’ but, for example, if we write @%=&20209 then this statement tells the computer to print in a field nine characters wide, and that number will be printed with a fixed number of decimal places – in this case, to two decimal places.

The following program shows this being used: 5 @%=&20209 10 X=7 20 PRINT X,X+2,X/3,X*X >RUN 7.00 9.00 2.33 49.00 For the more technically minded @ % is made up of a number of parts. & 2 02 09 Means hexadecimal numbers follow Format number 2 ie fixed number of decimal places Two decimal places characters Field width of nine @ %= &20309 would give Format 2, three decimal places and field width of nine characters. 5 @%=&20309 10 X=7 20 PRINT X,X+2,X/3,X*X >RUN 7.000 9.000 2.333 49.000 If you want four decimal places and a field width of 12 you would put the following: 5 @%=&2040C 10 X=7 20 PRINT X,X+2,X/3,X*X