[Jprogramming] How #: should have been designed
Dan Bron
j at bron.us
Tue Dec 13 03:09:54 HKT 2011
Maybe we should explore a different track. Forget all about the history of
computing hardware, and the advantages of one representation over another
when designing circuits. In purely mathematical terms, what are the decimal
digits of the base-10 number -123 ?
Working backwards:
_123 NB. begin
-123 NB. notation->operation
_1 * 123 NB. definition of -
_1 * (1 * 10^2) + (2 * 10^1) + ( 3 * 10^0) NB. positional number
notation
(_1 * 10^2) + (_2 * 10^1) + (_3 * 10^0) NB. distribution of * over +
_1 _2 _3 +/ . * 10^2 1 0 NB. array simplification
10 #. _1 _2 _3 NB. definition of #.
Thus, to satisfy the purposes of inversion, we should have:
[all examples from here on are purely theoretical, and the
results differ in the extant implementations of J]:
10 #.^:_1: _123
_1 _2 _3
And, analogously in base 2:
2 #.^:_1: 2b_101 NB. 2b_101 is J's notation
for -101 in base 2
_1 0 _1
#: 2b_101 NB. #: <=> 2&#.^:_1:
_1 0 _1
#: _5 NB. _5 <=> 2b_101 (numbers
are analytic)
_1 0 _1
QED.*
-Dan
* Backwards compatibility notwithstanding
PS: What implications does this have for modulus, as in _10 | 123 ?
More information about the Programming
mailing list