All pastes #914002 Raw Edit

Mine

public java v1 · immutable
·published 2008-02-22 15:29 UTC
rendered paste body
        public int[] numSub(int[] minuend, int[] subtrahend) {                // flip subtrahend                int arrayLength = minuend.length;                int[] flipped = new int[arrayLength];                for (int i=0; i<subtrahend.length; i++) {                        if (subtrahend[i] == 0)                                flipped[i] = 1;                        else    flipped[i] = 0;                }                for (int i=subtrahend.length; i<arrayLength; i++) flipped[i]=1;                // add one... = X                int[] one = {1};                int[] X = numAdd(one, flipped);                // add minuend and X, but drop the MSB.                int[] difference = numAdd(minuend, X);                difference[difference.length-1] = 0;                return difference;        }