its nice, just small fixed overhead

  timespacex '2147483647    *. bw/ 100000 $ 1234132123123 3123123123123 
55123231234423' 
0.00132 2.10202e6 
  timespacex '2147483647    (17 b.)/ 100000 $ 1234132123123 3123123123123 
55123231234423' 
0.00120416 2.10176e6 


overhead you get back easily in paren savings :)

a small nitpick, There are very cool extra features, but even though the 
overhead is very small, there should probably be a streamlined version that 
only handles primitives and named shifts

speaking of the shifts

signed_shift is undefined,

and my impression is that both the shifts should be defined as

|.!.0 NB. unsigned
|.!.1 NB. signed

After nitpicking to remove extras, an extra that would be cool is versions that 
work with extended integers.

#: inv x: (22 bw)/&#: 4294967295123123123 23423423423419238121x 
27564983555545902426

#: inv x: (22 bw)/&#: 23423423423419238122342342342330918282198066387871 
23423423423419238122342342342342342342342342342341x

ab2 =: #: :. ([: #. x:^:(62 < #))


  ~:/&.ab2 27564983555545902426 4294967295123123123x 
23423423423419238121





----- Original Message -----
From: Dan Bron <[email protected]>
To: J Programming <[email protected]>
Cc: 
Sent: Thursday, August 13, 2015 11:40 AM
Subject: [Jprogramming] Bitwise operations utility

I’ve been fiddling with J internals recently, and finding the need to twiddle 
bits.  I have a hard time maintaining the numeric b. codes in head, so I threw 
together a little utility that lets you say things like:

       2b00001000 +. bw 2b11110111
    255
       2b00001000 *. bw 2b11110111
    0
       2b00001000 > bw 2b11110111
    8
       2b00001000 -.@[ bw 2b11110111
    _9
       3 |. bw 2b11110111
    1976

It’s also got a bunch of other features I threw in as I was building it: 
primarily other ways of specifying which operation you want, and a way of 
looking up the details of any given operation.  For details, see the Note 
‘EXAMPLES’ at the bottom of the script.

Get it here:

    http://www.jsoftware.com/svn/DanBron/trunk/general/bitwise.ijs

Let me know if you find it useful - if enough people can make use of it, I’ll 
go through the effort of figuring out how to package and release it as a JAL 
addon.

I’m also interested in feedback on the coding style (which will be relevant if 
I release it as an addon; public code is held to higher standards).

-Dan

----------------------------------------------------------------------
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