I even had lousy data with no negative integers in test (I'm asshamed)

   ]N=:-50-100*?4 5$0
0.773157  20.5198   15.902 _35.0173  15.9508
 _34.929 _48.6306  46.9605 _1.52882  46.3141
 20.9279 _47.5387 _29.5731 0.816917 _22.7251
 40.8983 _25.4991  _32.985 _47.5215 _19.0724

(but code still worked except for qaussian numbers)

Nice Kip, Linda   
-----Original Message-----
From: Programming [mailto:[email protected]] On Behalf 
Of Raul Miller
Sent: Saturday, January 16, 2016 2:10 PM
To: Programming forum
Subject: Re: [Jprogramming] Round to integer

Hmm.. clearly not intended for gaussian integers.

   ri =: * * [: <. 0.5 + |
   ri 1j1
0.707107j0.707107

But I guess that's the thing about what we get taught... it tends to have only 
situational relevance.

Thanks,

--
Raul


On Sat, Jan 16, 2016 at 10:50 AM, Kip Murray <[email protected]> wrote:
> Here is my latest round-to-integer.  It rounds the absolute value and then
> restores the sign -- the way I was taught to round.  Apologies if someone
> else has already presented this.
>
>     ri =: * * [: <. 0.5 + |
>     ri _1234.56
>  _1235
>     ri 123.45
>  123
>
> --Kip Murray
>
>
> --
> Sent from Gmail Mobile
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

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

Reply via email to