Any simple "round to integer" will do.  Mine is more elaborate but
unnecessary for this example:

roundNums=: 3 : 0"1 0
NB.* roundNums: round numbers y to precision x, e.g.
NB. 0.1 roundNums 1.23 3.14159 2.718 -> 1.2 3.1 2.7.
NB. Optional 2nd left argument is single letter specifying
NB. type of rounding: Up, Down, or Banker's.  Default
NB. banker's rounding (round halves up or down depending on
NB. parity of next (scaled) digit) tends to randomize bias.
   1 roundNums y
:
   RT=. 'B'                  NB. Default to Banker's rounding
   TO=. x                   NB. Precision to which to round.
   if. (2=#x)*.1=L. x do. 'TO RT'=. x end.
   scaled=. y%TO            NB. For Banker's: round down if last digit even,
   select. RT
   case. 'B' do. RN=. 0.5*(0~:2|<.scaled)+.0.5~:1|scaled   NB. up if odd.
   case. 'D' do. RN=. (0.5=1|scaled){0 _0.5       NB. Round halves down.
   case. 'U' do. RN=. 0.5                         NB. Round halves up.
   end.
   TO*<.scaled+RN
)


On Sun, Mar 15, 2009 at 11:21 PM, Bill Harris <
[email protected]> wrote:

> Bill Harris <[email protected]> writes:
>
> > Devon McCormick <[email protected]> writes:
>
> >>    BGYPAL3=: roundNums |:BGYPAL3
> >
> > Tips as to what roundNums is?
>
> Something like 1 & round perhaps? :-)
>
> Bill
> --
> Bill Harris                      http://facilitatedsystems.com/weblog/
> Facilitated Systems                              Everett, WA 98208 USA
> http://facilitatedsystems.com/                  phone: +1 425 337-5541
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>



-- 
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to