Ethiopian multiplication: Difference between revisions

(Added XPL0)
Line 1,857:
}</lang>
 
 
=={{header|Objeck}}==
 
<lang objeck>
use Collection;
 
class EthiopianMultiplication {
function : Main(args : String[]) ~ Nil {
first := IO.Console->ReadString()->ToInt();
second := IO.Console->ReadString()->ToInt();
"----"->PrintLine();
Mul(first, second)->PrintLine();
}
function : native : Mul(first : Int, second : Int) ~ Int {
if(first < 0){
first := -1 * first;
second := -1 * second;
};
sum := isEven(first)? 0 : second;
do {
first := first >> 1;
second := second << 1;
if(isEven(first) = false){
sum += second;
};
}
while(first > 1);
return sum;
}
function : isEven(num : Int) ~ Bool {
return (num and 1) = 0;
}
}
</lang>
 
=={{header|OCaml}}==
760

edits