Hi all !
#: y is the binary representation ofy ,and is equivalent to(m#2)#:y
,wherem is the maximum of the number of digits needed to represent the
atoms ofy in base2 .
0 1 1 1 is +7 in two-complement form?
ndr=: 1 + <.@^. Number of digits required
ndr _9
3j3
showbin =: '01' {~ (64#2)&#:
showbin _9
1111111111111111111111111111111111111111111111111111111111110111
#: 7
1 1 1
The right argument should be cast to unsigned before the operation?
Cheers,
Erling Hellenäs
Den 2017-11-10 kl. 13:51, skrev Raul Miller:
Yes.
See https://en.wikipedia.org/wiki/Two's_complement for some discussion
of this issue.
Thanks,
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm