> From: Raul Miller
> 
> On Thu, Oct 15, 2009 at 4:58 PM, Eldon Eller <[email protected]>
> wrote:
> >   NB. stdval R returns the standard 1% resistor value nearest R.
> >
> > stdval=.10&^...@c*100&nrnd@(10&^@(96&(nrnd=.([:%[)*[:<.0.5"_+*)@(log-
> c=.[:<.log=.10&^.)))
> >
> 
> Anyways, here's how I would write what you have written.
> 
> log=: 10&^.
> nrnd=: [ %~ 0.5 <....@+ *
> stdval=: <.&.log * 100 nrnd 96 nrnd (- <.)&.log
> 

I don't think that gives the same results as Eldon's version. 

log=: 10&^.
nrnd0=: [ %~ 0.5 <....@+ *
stdval0=: <.&.log * 100 nrnd0 96 nrnd0 (- <.)&.log
(stdval -: stdval0) 0.012 0.01 5 3 2
0

This seems to:
log=: 10&^.
nrnd1=: %...@[ * 0.5 <....@+ *
stdval1=: (10&^@<. * 100 nrnd1 10 ^ 96 nrnd1 ] - <.)@log
   (stdval -: stdval1) 0.012 0.01 5 3 2
1

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to