Автор: Carl Whitwell,Paul Taylor
Год: 1988
Издатели: Your Sinclair
Языки:
Формат:
Требования:
Ссылки:
Скриншоты:
ROUND OFF
by Paul Taylor & Carl Whitwell
This letter must have taken a while to reach me 'cos it was addressed
to Task Force! But I'm going to print it anyway, 'cos it gives us two
useful rounding functions. Function one rounds off a number to the
nearest integer and takes account of numbers such as 2.5 where it
gives a result of three. The functions should be included in your
programs like this:
100 DEF FN r(v)=INT v+CODE CHR$ (v-INT(v))
110 DEF FN p(v,n)=FN r(v*10^n)/10^n
Function two, which uses Function one, rounds off a number to a
required number of decimal places. Have a butchers at the examples
below:
Command Output
PRINT FN r(2.4) 2
PRINT FN r(2.5) 3
PRINT FN p(123.0678,3) 123.068
PRINT FN p(123.0674,3) 123.067
These routines should speed up of almost any program which uses lots
of floating point maths, and needs to round off numbers. Yes, at last
you can write that Basic spreadsheet program you've always dreamed of
... (Oh brother! Ed)
by Paul Taylor & Carl Whitwell
This letter must have taken a while to reach me 'cos it was addressed
to Task Force! But I'm going to print it anyway, 'cos it gives us two
useful rounding functions. Function one rounds off a number to the
nearest integer and takes account of numbers such as 2.5 where it
gives a result of three. The functions should be included in your
programs like this:
100 DEF FN r(v)=INT v+CODE CHR$ (v-INT(v))
110 DEF FN p(v,n)=FN r(v*10^n)/10^n
Function two, which uses Function one, rounds off a number to a
required number of decimal places. Have a butchers at the examples
below:
Command Output
PRINT FN r(2.4) 2
PRINT FN r(2.5) 3
PRINT FN p(123.0678,3) 123.068
PRINT FN p(123.0674,3) 123.067
These routines should speed up of almost any program which uses lots
of floating point maths, and needs to round off numbers. Yes, at last
you can write that Basic spreadsheet program you've always dreamed of
... (Oh brother! Ed)