Ethiopian multiplication: Difference between revisions

m (→‎{{header|REXX}}: added the REXX language.)
Line 933:
<lang J> (<5) double 17
17 34 68 136 272</lang>
 
Note: this implementation assumes that the number on the right is a positive integer. In contexts where it can be negative, its absolute value should be used and you should multiply the result of ethiop by its sign.
 
<lang j>ethio=: *@] * (ethiop |)</lang>
 
Alternatively, if multiplying by negative 1 is prohibited, you can use a conditional function which optionally negates its argument.
 
<lang j>ethio=: *@] -@]^:(0 > [) (ethiop |)</lang>
 
Examples:
 
<lang j> 7 ethio 11
77
7 ethio _11
_77
_7 ethio 11
_77
_7 ethio _11
77</lang>
 
=={{header|Java}}==
6,962

edits