Accurate digital divider

Abstract: A digital divider (2,3) for forming the quotient (Q) of two numbers (A,B) includes means (4,5) providing values (Q + 1, Q - 1) of the quotient with possible rounding errors added to or subtracted therefrom. Selector switching means (7) is arranged to select one of the values (Q, Q + 1, Q - 1) under the control of a logic circuit operating according to the following rules.

Description: This invention concerns an accurate digital divider, and relates to an electronic device which is capable of forming the quotient of two numbers at high speed and without rounding errors. The device may also be adapted to provide an accurate remainder of the two numbers. The invention also concerns a process of division capable of being performed by such divider. It is well known to form the quotient of two numbers a/b by using the number b to access a table of precomputed quotients k/b where k is a number larger than the largest expected b, and then multiplying to form a(k/b) which is k times the required quotient. If k is chosen to be a power of the base to which calculations are performed, the base commonly being 2 for binary numbers, then dividing by k can be achieved by discarding the least significant digits. This method is described, for example, in Proceedings of the 10th IEEE Symposium on Computer Arithmetic, 26-28 June 1991, pages 186-190, R. Alversen: 'Integer Division Using Reciprocals'. However the method suffers from limitations of accuracy, the quotient often being in error by 1 or 2. It is accordingly an object of the invention to provide a division process and an accurate digital divider that overcomes the above problem. A further object of the invention is to provide such a process and device that is capable of providing the remainder of such a division, with greater accuracy. This object is achieved by the features of Claims 1, 3, 5 and 6. In order to aid understanding of the invention, an analysis of the process of division will be set out below. We must first define three operators / which is real number division, and gives a fractional result, div which applies only to integers, and produces a result which is the real number division of its operands rounded towards minus infinity, and rem which is the remainder when two numbers are divided. We are not concerned at this point with division by negative numbers. However, if two numbers are to be divided and one is negative, and we reverse the signs of both, the then the same quotient will be obtained. Hence we may observe the relationships that ( a div b ) * b + a rem b = a and therefore a / b = a div b + ( a rem b ) / b If we perform division by the known process described above, then, in attempting to evaluate a div b we really evaluate ( a * ( k div b ) ) div k = ( a * ( k - k rem b ) / b ) div k = ( k * ( a / b ) - a * ( k rem b ) / b ) div k = ( k * ( a div b ) + k * ( a rem b ) / b - a * ( k rem b ) / b) div k when we wanted ( k * ( a div b ) ) div k = a div b. We can rewrite the expression actually evaluated as ( k * ( a div b ) + e ) div k where e is an unknown error. Since k * ( a div b ) is, by definition, a multiple of k, if e is in the range -1 to -k the expression as a whole will be in error by -1, if e is in the range 0 to k-1 the expression will be correct. If we choose k to be larger than a or b then as e is in the range -a * ( b - 1 ) / b to k * ( b - 1 ) / b the error in the quotient is forced to be in the range -1 to zero. If a can take both positive and negative signs then the error can be either zero or of the opposite sign to a with a magnitude of 1. The invention is illustrated by way of example in the accompanying drawing, the single figure of which is a block circuit diagram of a device in accordance with the invention. Referring to the drawing, the values for the numbers from which the division is to be formed enter via the connections 1 which are normally parallel data buses carrying binary numbers. The look up table in the read-only memory 2 is used to form the quantity k div b where k is a suitably large number which is also a power of the base to which calculations are performed. This is multiplied by a and the result divided by k in the multiplier 3 in order to form the trial quotient Q. This is either a div b or in error by no more than 1. The adders 4 and 5 are used to add +1 and -1 to Q, and therefore the correct quotient is now present at one of these. In order to determine which, the selector 6 is used to choose either Q+1 if a is positive or Q if a is negative. The result of this selection is multiplied by b in the multiplier 8 and the result compared with a in the comparator 9. The sign of a and the result of the comparison are used to control the selector 7 which operates according to the following rules. A >= 0 and A >= ( Q + 1 ) * B use Q + 1 A >= 0 and A < ( Q + 1 ) * B use Q A < 0 and A >= Q * B use Q A < 0 and A < Q * B use Q - 1 The output of this selector is the required quantity a div b. If required a subtraction can also be made at 10. The result of this subtraction will be related to a rem b in the following way. A output Subtract giving result A >= 0 Q + 1 ( Q + 1 ) * B - A a rem b A >= 0 Q ( Q + 1 ) * B - A a rem b - b A < 0 Q Q * B - A a rem b A < 0 Q - 1 Q * B - A a rem b - b The result of this subtraction is then added to b by the adder 11 and the result of the comparison is used by the selector 12 to select either the output of 10 if it is positive or 11 if it is not, thus obtaining the remainder.

Claims: A digital electronic divider device for forming the quotient of two numbers a/b comprising a memory means (2) having an address input for receiving the number b and providing a lookup table of precomputed quotients k/b where k is a number larger than the largest expected number b and is a power of the base to which calculations are to be performed, a multiplier (3) having a first input coupled to the output of said memory device (2) and a second input to be addressed by the number a, and means for discarding the least significant digits of the value at the output of said multiplier, characterised in that said device further comprises means (4,5) coupled to the output of said discarding means for providing a plurality of different values of the quotient a/b comprising the values Q, Q+1 and Q-1, where Q is the output from said discarding means, selector switching means (7) for selecting one of said plurality of different values, and a logic circuit (8,9) coupled to receive digital values from selected signal paths of the device and arranged to actuate said selector switching means (7) to select one of said values in accordance with the following rules: Q when a> or = 0 and a< ( Q + 1 ) * b or when a< 0 and a> or = Q * b Q + 1 when a> or = 0 and a> or = ( Q + 1 ) * b Q - 1 when a< 0 and a< Q * b in order to determine an appropriate value of a/b in accordance with the relationship between the selected digital values. A device according to Claim 1, adapted to form the remainder of the division of said two numbers a/b and comprising a further multiplier (8) arranged to multiply one of said different value of a/b, selected in accordance with the value of a, by the value b provided at the address input of said memory means, subtractor means (10) for subtracting the value provided at the second input of the first multiplier (3) from the value provided at the output of the second multiplier (8) to form a first remainder value, an adder (11) arranged to add the value b provided at the address input of said memory means to the first remainder value provided at the output of said subtractor means (1O), to form a second remainder value, and a second selector switching means (12) coupled to said logic circuit and arranged to select an appropriate one of said remainder values. A digital electronic device for forming the remainder of the division of two numbers a/b, comprising a memory means (2) having an address input for receiving the number b and providing a look up table of precomputed quotients k/b where k is a number larger than the largest expected number b and is a power of the base to which calculations are to be performed, a multiplier (3) having a first input coupled to the output of said memory device (2) and a second input to be addressed by the number a, means for discarding the least significant digits of the value at the output of said multiplier (3), characterised in that said device further comprises means (3,4) coupled to the output of said discarding means for providing a plurality of different values of the quotient a/b comprising the values Q and Q+1, where Q is the output from said discarding means, selector switching means (6) arranged to select one of said values in accordance with the following rules: Q + 1 when a> or = 0 Q when a< 0 a further multiplier (8) arranged to multiply the value provided by the selector switching means (6) by the value b provided at the address input of said memory means (2), subtractor means (10) for subtracting the value provided at the second input of the first multiplier (3) from the value provided at the output of the second multiplier (8) to form a first remainder value, an adder (11) arranged to add the value b provided at the address input of said memory means (2) to the first remainder value provided at the output of said subtractor means (10), to form a second remainder value, and a second selector switching means (12) arranged to select an appropriate one of said remainder values. A device according to Claim 3 wherein said remainder value to be selected by said second selector switching means (12) is that one of the two remainder values that is greater than zero. A process for forming the quotient of two numbers a/b comprising the steps of: a) providing within a memory store a lookup table containing precomputed quotients k/b where k is a number larger than the largest expected number b and is a power of the base to which calculations are to be performed; b) addressing said store with the number b to obtain an output precomputed quotient; c) multiplying said output by the number a, and discarding the least significant digits of result; d) processing the result to provide the values Q, Q+1 and Q-1, where Q is the value obtained in step c), and e) selecting one of said values in accordance with the following rules: Q when a> or = 0 and a< ( Q + 1 ) * b or when a< 0 and a> or = Q * b Q + 1 when a> or = 0 and a> or = ( Q + 1 ) * b Q - 1 when a< 0 and a< Q * b A process for forming the remainder of two numbers a/b comprising the steps of: a) providing within a memory store a lookup table containing precomputed quotients k/b where k is a number larger than the largest expected number b and is a power of the base to which calculations are to be performed. b) addressing said store with the number b to obtain an output precomputed quotient; c) multiplying said output by the number a, and discarding the least significant digits of result; d) processing the result to provide a plurality of different values of the quotient a/b comprising the values Q and Q+1, where Q is the value obtained in step c); e) selecting one of said plurality of different values of a/b in accordance with the following rules: Q + 1 when a> or = 0 Q when a< 0. f) multiplying said appropriate value a/b by the number b used to address said store and subtracting a therefrom to form a first remainder value; g) adding b to said first remainder value to form a second remainder value; and h) determining on the basis of said logical comparison the correct value which forms the remainder of a/b.

Inventors: BILLING ROBERT, BILLING, ROBERT
Applicants: QUESTECH LTD, QUESTECH LIMITED
Application year: 1994
Main classification: G06F7
IPC codes: G06F7