WO2016047848A1 - Apparatus and method for calculating remainder - Google Patents

Apparatus and method for calculating remainder Download PDF

Info

Publication number
WO2016047848A1
WO2016047848A1 PCT/KR2014/010326 KR2014010326W WO2016047848A1 WO 2016047848 A1 WO2016047848 A1 WO 2016047848A1 KR 2014010326 W KR2014010326 W KR 2014010326W WO 2016047848 A1 WO2016047848 A1 WO 2016047848A1
Authority
WO
WIPO (PCT)
Prior art keywords
integer
result
binary number
remainder
adder
Prior art date
Application number
PCT/KR2014/010326
Other languages
French (fr)
Korean (ko)
Inventor
정석원
Original Assignee
(주)셀로직
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by (주)셀로직 filed Critical (주)셀로직
Publication of WO2016047848A1 publication Critical patent/WO2016047848A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/38Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation
    • G06F7/48Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation using non-contact-making devices, e.g. tube, solid state device; using unspecified devices

Definitions

  • the present invention relates to an apparatus for calculating a remainder and a method thereof, and more particularly, an apparatus for calculating a remainder for simply implementing a remainder on hardware by dividing a subtraction result of any two integers by a prime number. And to a method thereof.
  • ALUs arithmetic logic units
  • the division operation means the division of a number by another number by the inverse of the multiplication, and is also called a manufacturing method or division.
  • the divided number is the dividend
  • the divided number is the divisor
  • the answer is the quotient
  • the remainder is called the remainder.
  • the division is divided into equal parts that divide the dividend into numbers representing the divisor and inclusion agents indicating how many divisors are included in the dividend.
  • Prime number means a positive integer greater than 1 divided by 1 and itself, and 2, 3, 5, 7, 11, 13, 17, 19, and so on.
  • the present invention has been made in accordance with the above-described needs, and provides an apparatus and method for calculating the remainder for simplifying the hardware division of the result of subtracting any two integers into prime numbers. There is a purpose.
  • An apparatus for calculating a remainder is an apparatus for calculating a remainder obtained by dividing a result of subtraction of two integers by a prime number, and receiving a first integer and a second integer, respectively, each having an n-bit first A first converting unit and a second converting unit converting the binary number and the second binary number; A first adder configured to add the first binary number and the first binary number to which the second binary number is complemented; A second adder configured to add the second binary number and a reference integer determined corresponding to the decimal number; A third adder configured to add the first binary number and the first binary number to which the complementary result of the sum of the second adder is processed; And selecting a sum result of the first adder or a sum result of the third adder based on the magnitudes of the first and second integers, and wherein the first adder is greater than or equal to the second integer. And a control unit for determining the n-bit binary number included in the negative sum result as the remainder obtained by dividing the sub
  • the present invention may further include a first repair processing unit for repairing the second binary number and a second repair processing unit for repairing the sum result of the second addition unit.
  • the reference constant is set to t when the decimal is represented by 2 n -t.
  • the control unit determines that n-bit binary numbers included in the sum result of the third adder is the remainder of dividing the difference between the first integer and the second integer by a fraction. It is characterized by.
  • control unit determines that the first integer is greater than or equal to the second integer when the (n + 1) -th bit included in the sum of the first adder is 1, and (n + 1) included in the sum result. If the) th bit is 0, the first integer is determined to be less than the second integer.
  • a system comprising: a third conversion unit converting a binary number to a decimal number determined by the control unit by dividing the difference between the first integer and the second integer by a decimal number; And an output unit for outputting a decimal number converted by the third conversion unit.
  • a method for calculating a remainder obtained by dividing a result of subtraction of two integers by a prime number wherein the first transform unit and the second transform unit include a first integer and a second integer.
  • the n-bit binary number included in the sum result of the first addition unit may be determined as the remainder obtained by
  • the control unit In the determining of a result of dividing the difference between the first integer and the second integer by a fraction, the control unit, if the first integer is less than the second integer, n bits included in the sum result of the third adder The binary number of is determined as the remainder obtained by dividing the difference between the first integer and the second integer by a decimal number.
  • the reference integer may be set to t when the decimal point is expressed as 2 n -t.
  • control unit may determine that the (n + 1) -th bit included in the sum result of the first adder is 1; It is determined that one integer is greater than or equal to the second integer, and if the (n + 1) -th bit included in the sum result is 0, the first integer is determined to be less than the second integer.
  • the third conversion unit uses a decimal number determined by the remainder of the subtraction result of the subtraction of the first and second integers by a decimal number. Converting to; And an output unit outputting the converted decimal number.
  • the remainder obtained by subtracting the result of subtraction of two integers by a plurality of addition units regardless of the magnitude relationship between two integers, and after subtracting the result of subtraction of two integers by a decimal number according to the magnitude relationship of two integers By determining, we can compute the remainder faster.
  • the present invention can simply determine the magnitude relationship between two integers by checking the most significant bit included in the sum result.
  • FIG. 1 is a block diagram of an apparatus for calculating a remainder according to an embodiment of the present invention.
  • FIG. 2 is a flowchart illustrating an implementation process of a method of calculating a remainder according to an embodiment of the present invention.
  • FIG. 1 is a block diagram of an apparatus for calculating a remainder according to an embodiment of the present invention.
  • an apparatus for calculating a remainder includes a first converter 10, a second converter 20, a first adder 40, and a second adder 50. And a third adder 60 and a controller 70.
  • the first transform unit 10 and the second transform unit 20 convert the first integer and the second integer. It receives the input and converts the n-bit first binary number and the second binary number, respectively.
  • n bits means a bit set composed of n bits, and includes the first bit to the nth bit, the first bit corresponds to 2 0 , and the nth bit corresponds to 2 n-1 . Let's define.
  • first integer and the second integer, or the first binary number and the second binary number are freely determined according to the input order, and 1 or 2 may simply be an identifier for distinguishing two integers.
  • Decimals are positive integers greater than 1, dividing by 1 and themselves, so they can be represented as 2 n -t, where n and t are determined to be different values.
  • the bits of the first binary number and the second binary number converted by the first transform unit 10 and the second transform unit 20 are converted. Has a value of n bits because one bit is smaller than the bit corresponding to the number of bits (n + 1).
  • the first adder 40 adds a binary number, which has been complemented to a second binary number, a first binary number and 1, and the second adder 50 adds a reference integer determined corresponding to the second binary number and a decimal point.
  • the third adder 60 adds the binary number, the first binary number, and 1, which have been complemented, to the sum result of the second adder 50.
  • the complementary processing means to invert 0 or 1 of each bit of binary number represented by n bits.
  • the first integer is greater than or equal to the second integer, that is, the dividend is a positive integer
  • the following relationship is established.
  • removing 2 n means ignoring the (n + 1) th bit and using a value from the first bit to the n th bit.
  • Equation 3 The above-described "2 n + first integer-second integer” can be expressed by Equation 3 below.
  • ⁇ 2nd integer means processing the 2nd binary number which converted the 2nd integer.
  • the remainder obtained by subtracting the result of subtraction of the first integer and the second integer by a decimal number is the sum of the complementary binary number, the first binary number, and the first one. You can see that it is calculated in the form of.
  • the first adder 40 adds the binary number, the first binary number, and 1, which are complemented to the second binary number, and transfers the first binary number to the controller 70, which will be described later.
  • the sum result of the first adder 40 may be determined as the remainder obtained by dividing the subtraction result of the first integer and the second integer by a decimal number.
  • the remainder obtained by dividing the difference between the first integer and the second integer by a decimal number becomes "fraction + first integer-second integer".
  • the result of subtracting the first integer and the second integer divided by a decimal number is the sum of the complementary binary number, the first binary number, and 1 You can see that it is calculated in the form of.
  • the second adder 50 first adds t determined in correspondence with the second binary number and the decimal, and the third adder 60 compensates for the addition result of the second adder 50.
  • the processed binary number, the first binary number, and 1 are added to the control unit 70, and the control unit 70 transmits the sum result of the third adder 60 to the first integer when the first integer is less than the second integer.
  • the subtraction result of the second integer can be determined as the remainder divided by the decimal.
  • the first integer and the second integer are calculated. If only the magnitude relationship of integers is known, the sum result may be determined to be the remainder obtained by subtracting the first and second integer subtraction results by a decimal.
  • the sum of the first adder 40 indicates that the (n + 1) th bit is 1.
  • the controller 70 determines that the first integer is greater than or equal to the second integer when the (n + 1) th bit included in the sum of the first adder 40 is 1, and (n + 1) If the first bit is 0, it may be determined that the first integer is less than the second integer.
  • the bits included in the sum result of the first adder 40 are simply checked without any complicated calculation process, the magnitudes of the first and second integers may be easily determined. The remainder of the result of subtracting an integer and a second integer divided by a decimal number can be calculated.
  • the n-bit binary number included in the sum result of the first adder 40 may be determined as the remainder obtained by dividing the subtraction result of the first and second integers by a fraction. have.
  • n-bit binary numbers included in the summation result of the third adder 60 may be determined as the remainder obtained by dividing the subtraction result of the first integer and the second integer by a fraction. .
  • a plurality of complementary processing units 90 and 100 for performing the above-described complementary processing of the binary number and the complementary processing of the sum result of the second adder 50 may be included.
  • the first repair processing unit 90 repairs the second binary number
  • the second repair processing unit 100 repairs the sum result of the second adder 50.
  • first repair processing unit 90 and the second repair processing unit 100 may be configured as an inverter as shown in FIG. 1, but is not limited thereto. It may include any configuration.
  • the present embodiment may further include a third conversion unit 30 for converting a binary number to a decimal number, and an output unit 80 for outputting an operation result.
  • the third converter 30 converts the remainder obtained by subtracting the subtraction result of the first integer and the second integer determined by the controller 70 into decimal numbers to be intuitively recognized by the user, and outputs the output unit 80. Outputs a decimal number converted by the third conversion unit 30.
  • FIG. 2 is a flowchart illustrating an implementation process of a method of calculating a remainder according to an embodiment of the present invention.
  • the first transform unit 10 and the second transform unit 20 inputs the first integer and the second integer
  • the first binary number and the second binary number are respectively converted into n bits (S10).
  • the first adder 40 adds the first binary number and the first binary number to which the second binary number is repaired through the first complement processing unit 90 (S20).
  • step S40 the binary number, the first binary number, and 1, which are complemented with the summation result, are added.
  • the controller 70 determines the remainder obtained by dividing the subtraction result of the first integer and the second integer by a decimal number based on the magnitude of the first integer and the second integer (S50).
  • the operation is performed through separate adders 40 to 60, which are placed in parallel (S20 to S40). If only the magnitude relationship between the first integer and the second integer is known, the corresponding summation result can be determined to be the remainder of the subtraction of the first and second integers divided by the decimal.
  • control unit 70 divides the n-bit binary number included in the sum result of the first adder 40 by dividing the result of subtracting the first integer from the second integer by a decimal number. Determine (S60).
  • the control unit 70 divides the n-bit binary number included in the sum result of the third adder 60 by dividing the subtraction result of the first integer and the second integer by a fraction. Determine (S62).
  • a simple operation is performed in a different manner according to the magnitude relationship between the first integer and the second integer, and any operation result is reflected by the magnitude relationship between the first integer and the second integer. Determines whether two integer subtraction results are divided by decimals.
  • the third conversion unit 30 converts the binary number determined by dividing the subtraction result of the first integer and the second integer into decimals (S70), and the output unit 80 outputs the converted decimal number to the user. Lets simply check the remainder of the difference between the first integer and the second integer divided by a decimal number.
  • the remainder obtained by subtracting the result of subtraction of two integers through a plurality of adders regardless of the magnitude relationship of two integers, and later subtracting the result of subtraction of two integers by a decimal number according to the magnitude relationship of two integers
  • the present embodiment can simply determine the magnitude relationship of two integers by checking the most significant bit included in the sum result.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computational Mathematics (AREA)
  • Computing Systems (AREA)
  • Mathematical Analysis (AREA)
  • Mathematical Optimization (AREA)
  • Pure & Applied Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Complex Calculations (AREA)

Abstract

The present invention relates to an apparatus for calculating a remainder, the apparatus, which calculates the remainder of dividing the result of a subtraction of two integers by a prime number, comprising: a first conversion unit and a second conversion unit for receiving input of a first integer and a second integer and converting same into a first binary number and a second binary number of n bits, respectively; a first addition unit for summing a binary complement of the second binary number, the first binary number and 1; a second addition unit for summing the reference integers determined in accordance with the second binary number and prime number; a third addition unit for summing the binary complement of the resulting sum of the second addition unit, the first binary number and 1; a control unit for selecting one from among the resulting sum of the first addition unit and the resulting sum of the third addition unit on the basis of the size of first integer and second integer, wherein if the first integer is equal to or greater than the second integer, then concluding the binary number of n bits contained in the resulting sum of the first addition unit as the remainder of dividing the result of the subtraction of first and second integers by the prime number.

Description

나머지를 연산하는 장치 및 그 방법Apparatus and method for calculating the remainder
본 발명은 나머지를 연산하는 장치 및 그 방법에 관한 것으로서, 더욱 상세하게는 임의의 두 정수의 뺄셈 결과를 소수(Prime number)로 나눈 나머지를 하드웨어 상으로 간단하게 구현하기 위한, 나머지를 연산하는 장치 및 그 방법에 관한 것이다.The present invention relates to an apparatus for calculating a remainder and a method thereof, and more particularly, an apparatus for calculating a remainder for simply implementing a remainder on hardware by dividing a subtraction result of any two integers by a prime number. And to a method thereof.
기존의 산술 논리 연산 장치(ALU)는 가산기(Adder)를 기반으로 덧셈 연산 뿐만 아니라, 뺄셈 연산 등의 다양한 산술 연산과 논리합, 논리곱 등의 다양한 논리 연산을 수행하고 있다.Conventional arithmetic logic units (ALUs) perform not only addition operations based on adders, but also various arithmetic operations, such as subtraction operations, and various logical operations such as OR and OR.
그 중에서, 나눗셈 연산은 곱셈의 역산으로 어떤 수를 다른 수로 나누는 셈을 의미하며, 제법 또는 제산이라고도 한다. 이 때, 나누어지는 수를 피제수, 나누는 수를 제수, 답을 몫, 나누어 떨어지지 않고 남은 수를 나머지(Remainder)라고 한다.Among them, the division operation means the division of a number by another number by the inverse of the multiplication, and is also called a manufacturing method or division. At this time, the divided number is the dividend, the divided number is the divisor, the answer is the quotient, and the remainder that is not divided is called the remainder.
나눗셈은 피제수를 제수가 나타내는 수로 등분하는 등분제와, 피제수 속에 제수가 얼마나 포함되어 있는지를 나타내는 포함제로 구분된다.The division is divided into equal parts that divide the dividend into numbers representing the divisor and inclusion agents indicating how many divisors are included in the dividend.
나눗셈에서 분배법칙은 성립하지 않으나 일반적으로 a÷b÷c=a÷c÷b=a÷(b×c)는 성립하고, a÷b=(a×c)÷(b×c)=(a÷c)÷(b÷c)도 성립한다. In division, the distribution law does not hold, but in general, a ÷ b ÷ c = a ÷ c ÷ b = a ÷ (b × c), and a ÷ b = (a × c) ÷ (b × c) = ( a ÷ c) ÷ (b ÷ c) is also established.
또한, 피제수 및 제수에 0이 있을 때 0÷a=0(a≠0)이며, 0÷0의 몫은 부정, a÷0은 불능이 된다.In addition, when dividend and divisor have 0, 0 ÷ a = 0 (a ≠ 0), the quotient of 0 ÷ 0 is negative, and a ÷ 0 is disabled.
본 발명과 관련된 선행기술로는 대한민국 공개특허공보 10-1997-0059919 호(1997.08.12.공개, 발명의 명칭 : 나머지 계산방법 및 회로)가 있다.Prior art related to the present invention is Republic of Korea Patent Publication No. 10-1997-0059919 (published Aug. 12, 1997, the title of the invention: the remaining calculation method and circuit).
소수(Prime number)는 1과 자기 자신만으로 나누어 떨어지는 1보다 큰 양의 정수를 의미하고, 2, 3, 5, 7, 11, 13, 17, 19 등이 이에 해당한다.Prime number means a positive integer greater than 1 divided by 1 and itself, and 2, 3, 5, 7, 11, 13, 17, 19, and so on.
이 때, 소수보다 작은 값을 갖는 임의의 두 정수에 대해서, 두 정수의 뺄셈 결과를 소수로 나눈 나머지를 연산할 때 두 정수의 뺄셈 결과는 0이상인 경우와 0보다 작은 경우에 연산 과정은 서로 상이하다.In this case, for any two integers having a value less than a decimal, when the remainder of subtracting two integers divided by a decimal number, the two subtraction results are different from each other if the result is greater than zero or less than zero. Do.
따라서, 종래에는 임의의 두 정수의 뺄셈 결과를 소수로 나눈 나머지를 연산할 때, 임의의 두 정수의 대소 관계를 먼저 판단하고 그 판단 결과에 따라서 서로 다른 방식으로 나머지를 연산하고 있었다.Therefore, in the related art, when calculating a remainder obtained by subtracting a result of an arbitrary two integers divided by a decimal number, a case relation of two arbitrary integers is first determined, and the remainder is calculated in different ways according to the determination result.
이와 같이 종래에는 임의의 두 정수를 먼저 빼고 그 결과에 따라서 어떠한 방식으로 나머지를 연산할 것인지 결정하는 과정이 우선 수행되어야 했기 때문에, 연산 결과가 도출되는 시간이 오래 걸렸고 이를 단축할 필요성이 있었다.As such, in the related art, since a process of deciding which two integers are to be subtracted first and which method is to be calculated according to the result has to be performed first, it takes a long time for the calculation result to be derived and it is necessary to shorten it.
본 발명은 전술한 필요성에 따라 창안된 것으로서, 임의의 두 정수의 뺄셈 결과를 소수(Prime number)로 나눈 나머지를 하드웨어 상으로 간단하게 구현하기 위한, 나머지를 연산하는 장치 및 그 방법을 제공하는데 그 목적이 있다.SUMMARY OF THE INVENTION The present invention has been made in accordance with the above-described needs, and provides an apparatus and method for calculating the remainder for simplifying the hardware division of the result of subtracting any two integers into prime numbers. There is a purpose.
본 발명의 일 측면에 따른 나머지를 연산하는 장치는 두 정수의 뺄셈 결과를 소수(Prime number)로 나눈 나머지를 연산하는 장치에 있어서, 제1정수와 제2정수를 입력받아 각각 n비트의 제1이진수와 제2이진수로 변환하는 제1변환부, 제2변환부; 상기 제2이진수를 보수 처리한 이진수와 상기 제1이진수 및 1을 합산하는 제1덧셈부; 상기 제2이진수와 상기 소수에 대응하여 결정되는 기준정수를 합산하는 제2덧셈부; 상기 제2덧셈부의 합산 결과를 보수 처리한 이진수와 상기 제1이진수 및 1을 합산하는 제3덧셈부; 및 상기 제1정수와 제2정수의 대소에 기초하여 상기 제1덧셈부의 합산 결과 또는 상기 제3덧셈부의 합산 결과 중 하나를 선택하되, 상기 제1정수가 상기 제2정수 이상이면 상기 제1덧셈부의 합산 결과에 포함된 n비트의 이진수를, 상기 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 나머지로 결정하는 제어부를 포함한다.An apparatus for calculating a remainder according to an aspect of the present invention is an apparatus for calculating a remainder obtained by dividing a result of subtraction of two integers by a prime number, and receiving a first integer and a second integer, respectively, each having an n-bit first A first converting unit and a second converting unit converting the binary number and the second binary number; A first adder configured to add the first binary number and the first binary number to which the second binary number is complemented; A second adder configured to add the second binary number and a reference integer determined corresponding to the decimal number; A third adder configured to add the first binary number and the first binary number to which the complementary result of the sum of the second adder is processed; And selecting a sum result of the first adder or a sum result of the third adder based on the magnitudes of the first and second integers, and wherein the first adder is greater than or equal to the second integer. And a control unit for determining the n-bit binary number included in the negative sum result as the remainder obtained by dividing the subtraction result of the first and second integers by a decimal number.
본 발명은 상기 제2이진수를 보수 처리하는 제1보수 처리부와 상기 제2덧셈부의 합산 결과를 보수 처리하는 제2보수 처리부를 더 포함하는 것을 특징으로 한다.The present invention may further include a first repair processing unit for repairing the second binary number and a second repair processing unit for repairing the sum result of the second addition unit.
본 발명에서 상기 기준정수는 상기 소수를 2n - t로 표현했을 때 t로 설정되는 것을 특징으로 한다.In the present invention, the reference constant is set to t when the decimal is represented by 2 n -t.
본 발명에서 상기 제어부는 상기 제1정수가 상기 제2정수 미만이면 상기 제3덧셈부의 합산 결과에 포함된 n비트의 이진수를 상기 제1정수와 제2정수의 차를 소수로 나눈 나머지로 결정하는 것을 특징으로 한다.In the present invention, if the first integer is less than the second integer, the control unit determines that n-bit binary numbers included in the sum result of the third adder is the remainder of dividing the difference between the first integer and the second integer by a fraction. It is characterized by.
본 발명에서 상기 제어부는 상기 제1덧셈부의 합산 결과에 포함된 (n+1)번째 비트가 1이면 상기 제1정수가 상기 제2정수 이상인 것으로 판단하고, 상기 합산 결과에 포함된 (n+1)번째 비트가 0이면 상기 제1정수가 상기 제2정수 미만인 것으로 판단하는 것을 특징으로 한다.In the present invention, the control unit determines that the first integer is greater than or equal to the second integer when the (n + 1) -th bit included in the sum of the first adder is 1, and (n + 1) included in the sum result. If the) th bit is 0, the first integer is determined to be less than the second integer.
본 발명은 상기 제어부에 의해 상기 제1정수와 제2정수의 차를 소수로 나눈 나머지로 결정되는 이진수를 십진수로 변환하는 제3변환부; 및 상기 제3변환부에서 변환되는 십진수를 출력하는 출력부를 더 포함하는 것을 특징으로 한다.According to an aspect of the present invention, there is provided a system comprising: a third conversion unit converting a binary number to a decimal number determined by the control unit by dividing the difference between the first integer and the second integer by a decimal number; And an output unit for outputting a decimal number converted by the third conversion unit.
본 발명의 일 측면에 따른 나머지를 연산하는 방법은 두 정수의 뺄셈 결과를 소수(Prime number)로 나눈 나머지를 연산하는 방법에 있어서, 제1변환부와 제2변환부가 제1정수와 제2정수를 입력받아 각각 n비트의 제1이진수와 제2이진수로 변환하는 단계; 제1덧셈부가 상기 제2이진수를 보수 처리한 이진수와 상기 제1이진수 및 1을 합산하는 단계; 제2덧셈부가 상기 제2이진수와 상기 소수에 대응하여 결정되는 기준정수를 합산하는 단계; 제3덧셈부가 상기 제2덧셈부의 합산 결과를 보수 처리한 이진수와 상기 제1이진수 및 1을 합산하는 단계; 및 제어부가 상기 제1정수와 제2정수의 대소에 기초하여 상기 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 결과를 결정하는 단계를 포함하되, 상기 제어부는 상기 제1정수가 상기 제2정수 이상이면 상기 제1덧셈부의 합산 결과에 포함된 n비트의 이진수를, 상기 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 나머지로 결정하는 것을 특징으로 한다.According to an aspect of the present invention, there is provided a method for calculating a remainder obtained by dividing a result of subtraction of two integers by a prime number, wherein the first transform unit and the second transform unit include a first integer and a second integer. Receiving and converting the n-bit first and second binary numbers, respectively; Adding a first binary addition and a complementary binary number by the first addition unit to the first binary number and 1; Summing a second integer and a reference integer determined in correspondence with the decimal part; Adding a third binary addition-complementary binary number, the first binary number and the first one, of which the complementary result of the second addition unit is added; And determining, by the controller, a result of dividing the subtraction result of the first integer and the second integer by a decimal number based on the magnitude of the first and second integers, wherein the controller is configured to determine the first integer. In the case of two or more integers, the n-bit binary number included in the sum result of the first addition unit may be determined as the remainder obtained by dividing the subtraction result of the first and second integers by a decimal number.
본 발명의 상기 제1정수와 제2정수의 차를 소수로 나눈 결과를 결정하는 단계에서, 상기 제어부는 상기 제1정수가 상기 제2정수 미만이면 상기 제3덧셈부의 합산 결과에 포함된 n비트의 이진수를 상기 제1정수와 제2정수의 차를 소수로 나눈 나머지로 결정하는 것을 특징으로 한다.In the determining of a result of dividing the difference between the first integer and the second integer by a fraction, the control unit, if the first integer is less than the second integer, n bits included in the sum result of the third adder The binary number of is determined as the remainder obtained by dividing the difference between the first integer and the second integer by a decimal number.
본 발명의 상기 제2이진수와 상기 소수에 대응하여 결정되는 기준정수를 합산하는 단계에서, 상기 기준정수는 상기 소수를 2n - t로 표현했을 때 t로 설정되는 것을 특징으로 한다.In the step of summing the second binary number of the present invention and a reference constant determined corresponding to the decimal point, the reference integer may be set to t when the decimal point is expressed as 2 n -t.
본 발명의 상기 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 나머지를 결정하는 단계에서, 상기 제어부는 상기 제1덧셈부의 합산 결과에 포함된 (n+1)번째 비트가 1이면 상기 제1정수가 상기 제2정수 이상인 것으로 판단하고, 상기 합산 결과에 포함된 (n+1)번째 비트가 0이면 상기 제1정수가 상기 제2정수 미만인 것으로 판단하는 것을 특징으로 한다.In the determining of the remainder obtained by dividing the subtraction result of the first integer and the second integer by a decimal number, the control unit may determine that the (n + 1) -th bit included in the sum result of the first adder is 1; It is determined that one integer is greater than or equal to the second integer, and if the (n + 1) -th bit included in the sum result is 0, the first integer is determined to be less than the second integer.
본 발명은 상기 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 나머지를 결정한 이후에, 제3변환부가 상기 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 나머지로 결정되는 이진수를 십진수로 변환하는 단계; 및 출력부가 상기 변환되는 십진수를 출력하는 단계를 더 포함하는 것을 특징으로 한다.According to the present invention, after determining the remainder obtained by subtracting the subtraction result of the first integer and the second integer by a decimal number, the third conversion unit uses a decimal number determined by the remainder of the subtraction result of the subtraction of the first and second integers by a decimal number. Converting to; And an output unit outputting the converted decimal number.
본 발명에 따르면, 두 정수의 대소 관계와 무관하게 복수의 덧셈부를 통해서 두 정수의 뺄셈 결과를 소수로 나눈 나머지를 연산하고, 나중에 두 정수의 대소 관계에 따라 두 정수의 뺄셈 결과를 소수로 나눈 나머지를 결정함으로써 보다 빠르게 나머지를 연산할 수 있다.According to the present invention, the remainder obtained by subtracting the result of subtraction of two integers by a plurality of addition units regardless of the magnitude relationship between two integers, and after subtracting the result of subtraction of two integers by a decimal number according to the magnitude relationship of two integers By determining, we can compute the remainder faster.
또한 본 발명은 합산 결과에 포함된 최상위 비트를 확인하는 방식으로 간단하게 두 정수의 대소 관계를 판단할 수 있다.In addition, the present invention can simply determine the magnitude relationship between two integers by checking the most significant bit included in the sum result.
도 1은 본 발명의 일 실시예에 따른 나머지를 연산하는 장치의 블록 구성도이다.1 is a block diagram of an apparatus for calculating a remainder according to an embodiment of the present invention.
도 2는 본 발명의 일 실시예에 따른 나머지를 연산하는 방법의 구현 과정을 설명하는 절차 흐름도이다.2 is a flowchart illustrating an implementation process of a method of calculating a remainder according to an embodiment of the present invention.
이하에서는 본 발명의 일 실시예에 따른 나머지를 연산하는 장치 및 그 방법을 첨부된 도면들을 참조하여 상세하게 설명한다. 이 과정에서 도면에 도시된 선들의 두께나 구성요소의 크기 등은 설명의 명료성과 편의상 과장되게 도시되어 있을 수 있다. 또한, 후술되는 용어들은 본 발명에서의 기능을 고려하여 정의된 용어들로서 이는 사용자, 운용자의 의도 또는 관례에 따라 달라질 수 있다. 그러므로, 이러한 용어들에 대한 정의는 본 명세서 전반에 걸친 내용을 토대로 내려져야 할 것이다.Hereinafter, an apparatus and method for calculating a remainder according to an embodiment of the present invention will be described in detail with reference to the accompanying drawings. In this process, the thickness of the lines or the size of the components shown in the drawings may be exaggerated for clarity and convenience of description. In addition, terms to be described below are terms defined in consideration of functions in the present invention, which may vary according to the intention or convention of a user or an operator. Therefore, definitions of these terms should be made based on the contents throughout the specification.
도 1은 본 발명의 일 실시예에 따른 나머지를 연산하는 장치의 블록 구성도이다.1 is a block diagram of an apparatus for calculating a remainder according to an embodiment of the present invention.
도 1을 참조하면 본 발명의 일 실시예에 따른 나머지를 연산하는 장치는 제1변환부(10), 제2변환부(20), 제1덧셈부(40), 제2덧셈부(50), 제3덧셈부(60) 및 제어부(70)를 포함한다.Referring to FIG. 1, an apparatus for calculating a remainder according to an embodiment of the present invention includes a first converter 10, a second converter 20, a first adder 40, and a second adder 50. And a third adder 60 and a controller 70.
구체적으로 본 실시예에서는 두 정수(U, V)의 뺄셈 결과를 소수(Prime number)로 나눈 나머지를 연산하되, 소수와 두 정수의 관계는 아래의 수학식 1과 같다.Specifically, in the present embodiment, the remainder obtained by dividing the result of subtraction of two integers (U, V) by a prime number is calculated, but the relationship between the decimal and the two integers is expressed by Equation 1 below.
수학식 1
Figure PCTKR2014010326-appb-M000001
Equation 1
Figure PCTKR2014010326-appb-M000001
즉, 본 실시예에서는 각각 소수보다 작은 두 정수의 뺄셈 결과를 소수로 나눈 나머지를 간편하게 연산하기 위해서, 제1변환부(10)와 제2변환부(20)는 제1정수와 제2정수를 입력받아 각각 n비트의 제1이진수와 제2이진수로 변환한다.That is, in the present embodiment, in order to easily calculate the remainder obtained by subtracting the result of subtraction of two integers each smaller than the decimal, the first transform unit 10 and the second transform unit 20 convert the first integer and the second integer. It receives the input and converts the n-bit first binary number and the second binary number, respectively.
본 실시예에서 n비트라는 의미는 n개의 비트로 이루어진 비트 집합을 의미하는 것으로, 첫번째 비트에서 n번째 비트까지 포함하고, 첫번째 비트는 20에 대응하고 n번째 비트는 2n-1에 대응하는 것으로 정의하기로 한다.In the present embodiment, n bits means a bit set composed of n bits, and includes the first bit to the nth bit, the first bit corresponds to 2 0 , and the nth bit corresponds to 2 n-1 . Let's define.
또한, 제1정수와 제2정수, 또는 제1이진수와 제2이진수는 입력되는 순서 등에 따라 자유롭게 결정되는 값으로 1이나 2는 단순히 두 정수를 구별하기 위한 식별자라고 할 수 있다.In addition, the first integer and the second integer, or the first binary number and the second binary number are freely determined according to the input order, and 1 or 2 may simply be an identifier for distinguishing two integers.
이하에서는 제1정수에서 제2정수를 뺀 수를 소수로 나눈 나머지를 연산하는 경우를 예로 설명하기로 한다.Hereinafter, an example of calculating a remainder obtained by dividing a number by subtracting a second integer from a first integer by a decimal number will be described.
소수는 1과 자기 자신만으로 나누어 떨어지는 1보다 큰 양의 정수이기 때문에 2n - t와 같은 형태로 나타낼 수 있고, 소수에 따라서 n과 t는 다른 값으로 결정된다.Decimals are positive integers greater than 1, dividing by 1 and themselves, so they can be represented as 2 n -t, where n and t are determined to be different values.
그리고, 전술한 바와 같이 제1정수와 제2정수는 소수보다 작은 정수로 가정하였기 때문에, 제1변환부(10)와 제2변환부(20)에서 변환하는 제1이진수와 제2이진수의 비트는 소수의 비트수(n+1)에 해당하는 비트보다 한 비트가 작으므로 n비트의 값을 갖는다.As described above, since the first integer and the second integer are assumed to be integers smaller than a decimal number, the bits of the first binary number and the second binary number converted by the first transform unit 10 and the second transform unit 20 are converted. Has a value of n bits because one bit is smaller than the bit corresponding to the number of bits (n + 1).
제1덧셈부(40)는 제2이진수를 보수 처리한 이진수와 제1이진수 및 1을 합산하고, 제2덧셈부(50)는 제2이진수와 소수에 대응하여 결정되는 기준정수를 합산하며, 제3덧셈부(60)는 제2덧셈부(50)의 합산 결과를 보수 처리한 이진수와 제1이진수 및 1을 합산한다.The first adder 40 adds a binary number, which has been complemented to a second binary number, a first binary number and 1, and the second adder 50 adds a reference integer determined corresponding to the second binary number and a decimal point. The third adder 60 adds the binary number, the first binary number, and 1, which have been complemented, to the sum result of the second adder 50.
이 때, 보수 처리한다는 것은 n비트로 표현된 이진수의 각 비트의 0 또는 1을 반전시키는 것을 의미한다.At this time, the complementary processing means to invert 0 or 1 of each bit of binary number represented by n bits.
어떤 수를 나누었을 때 나머지를 연산하는 과정은 나누어지는 수인 피제수가 양수인지 음수인지에 따라 달라지므로, 피제수가 양의 정수인 경우와 음의 정수인 경우를 나누어서 검토하기로 한다.Since the process of calculating the remainder when a number is divided depends on whether the dividend is a positive or negative number, the case is divided into a positive integer and a negative integer.
먼저 제1정수가 제2정수 이상, 즉 피제수가 양의 정수인 경우에, 아래의 수학식 2와 같은 관계가 성립한다.First, in the case where the first integer is greater than or equal to the second integer, that is, the dividend is a positive integer, the following relationship is established.
수학식 2
Figure PCTKR2014010326-appb-M000002
Equation 2
Figure PCTKR2014010326-appb-M000002
따라서 "2n + 제1정수 - 제2정수"를 피제수로 하여 소수로 나눈 나머지를 연산하고, 연산 후에 2n을 제거하여도 동일한 나머지 결과를 얻을 수 있다.Therefore, the remainder obtained by dividing " 2n + 1st integer-2nd integer" as a dividend by a decimal number and removing 2n after the operation can obtain the same result.
이 때, 본 실시예에서는 이진수 형태로 나머지를 연산하기 때문에 2n을 제거한다는 것은 (n+1)번째 비트를 무시하고, 첫번째 비트부터 n번째 비트까지의 값을 이용한다는 의미가 된다.At this time, in this embodiment, since the remainder is calculated in binary form, removing 2 n means ignoring the (n + 1) th bit and using a value from the first bit to the n th bit.
그리고 전술한 "2n + 제1정수 - 제2정수"는 아래의 수학식 3과 같이 나타낼 수 있다.The above-described "2 n + first integer-second integer" can be expressed by Equation 3 below.
수학식 3
Figure PCTKR2014010326-appb-M000003
Equation 3
Figure PCTKR2014010326-appb-M000003
Figure PCTKR2014010326-appb-I000001
Figure PCTKR2014010326-appb-I000001
이 때, "~제2정수"는 제2정수가 변환된 제2이진수를 보수 처리하는 것을 의미한다.At this time, "~ 2nd integer" means processing the 2nd binary number which converted the 2nd integer.
수학식 3에 나타난 바와 같이 제1정수가 제2정수 이상인 경우에, 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 나머지는 제2이진수를 보수 처리한 이진수와 제1이진수 및 1을 합산하는 형식으로 연산됨을 확인할 수 있다.As shown in Equation 3, when the first integer is greater than or equal to the second integer, the remainder obtained by subtracting the result of subtraction of the first integer and the second integer by a decimal number is the sum of the complementary binary number, the first binary number, and the first one. You can see that it is calculated in the form of.
따라서, 본 실시예에서 제1덧셈부(40)는 제2이진수를 보수 처리한 이진수와 제1이진수 및 1을 합산하여 후술하는 제어부(70)로 전달하고, 제어부(70)는 제1정수가 제2정수 이상인 경우에 제1덧셈부(40)의 합산 결과를 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 나머지로 판단할 수 있다.Therefore, in the present exemplary embodiment, the first adder 40 adds the binary number, the first binary number, and 1, which are complemented to the second binary number, and transfers the first binary number to the controller 70, which will be described later. In the case of more than the second integer, the sum result of the first adder 40 may be determined as the remainder obtained by dividing the subtraction result of the first integer and the second integer by a decimal number.
다음으로, 제1정수가 제2정수 미만, 즉 피제수가 음의 정수인 경우에, 제1정수와 제2정수의 차를 소수로 나눈 나머지는 "소수 + 제1정수 - 제2정수"가 된다.Next, when the first integer is less than the second integer, that is, the dividend is a negative integer, the remainder obtained by dividing the difference between the first integer and the second integer by a decimal number becomes "fraction + first integer-second integer".
그리고 이를 변경하면 아래의 수학식 4와 같이 나타낼 수 있다.If this is changed, it can be expressed as Equation 4 below.
수학식 4
Figure PCTKR2014010326-appb-M000004
Equation 4
Figure PCTKR2014010326-appb-M000004
Figure PCTKR2014010326-appb-I000003
Figure PCTKR2014010326-appb-I000003
즉, 제1정수가 제2정수 미만인 경우에 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 나머지는 제2이진수와 t를 합산한 결과를 보수 처리한 이진수와 제1이진수 및 1을 합산하는 형식으로 연산됨을 확인할 수 있다.That is, when the first integer is less than the second integer, the result of subtracting the first integer and the second integer divided by a decimal number is the sum of the complementary binary number, the first binary number, and 1 You can see that it is calculated in the form of.
따라서, 본 실시예에서 제2덧셈부(50)는 먼저 제2이진수와 소수에 대응하여 결정되는 t를 합산하고, 제3덧셈부(60)는 제2덧셈부(50)의 합산 결과를 보수 처리한 이진수와 제1이진수 및 1을 합산하여 제어부(70)로 전달하고, 제어부(70)는 제1정수가 제2정수 미만인 경우에 제3덧셈부(60)의 합산 결과를 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 나머지로 판단할 수 있다.Therefore, in the present embodiment, the second adder 50 first adds t determined in correspondence with the second binary number and the decimal, and the third adder 60 compensates for the addition result of the second adder 50. The processed binary number, the first binary number, and 1 are added to the control unit 70, and the control unit 70 transmits the sum result of the third adder 60 to the first integer when the first integer is less than the second integer. The subtraction result of the second integer can be determined as the remainder divided by the decimal.
전술한 바와 같이, 본 실시예에서는 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 나머지를 병렬로 위치하는 별개의 덧셈부(40 내지 60)를 통해서 연산하기 때문에, 제1정수와 제2정수의 대소 관계만을 알 수 있으면 그에 해당하는 합산 결과가 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 나머지인 것으로 결정하여 출력할 수 있다.As described above, in the present embodiment, since the result of subtraction of the first integer and the second integer is calculated through separate adders 40 to 60 positioned in parallel, the first integer and the second integer are calculated. If only the magnitude relationship of integers is known, the sum result may be determined to be the remainder obtained by subtracting the first and second integer subtraction results by a decimal.
그리고, 전술한 바와 같이 제1정수가 제2정수 이상인 경우에는 2n을 합산하였기 때문에, 제1덧셈부(40)의 합산 결과는 (n+1)번째 비트가 1로 나타난다.As described above, when the first integer is equal to or greater than the second integer, since 2 n is added, the sum of the first adder 40 indicates that the (n + 1) th bit is 1.
따라서 본 실시예에서 제어부(70)는 제1덧셈부(40)의 합산 결과에 포함된 (n+1)번째 비트가 1이면 제1정수가 제2정수 이상인 것으로 판단하고, (n+1)번째 비트가 0이면 제1정수가 제2정수 미만인 것으로 판단할 수 있다.Therefore, in the present exemplary embodiment, the controller 70 determines that the first integer is greater than or equal to the second integer when the (n + 1) th bit included in the sum of the first adder 40 is 1, and (n + 1) If the first bit is 0, it may be determined that the first integer is less than the second integer.
즉, 본 실시예에서는 별도의 복잡한 연산 과정없이, 제1덧셈부(40)의 합산 결과에 포함된 비트를 확인하여 간단하게 제1정수와 제2정수의 대소를 판단할 수 있기 때문에 빠르게 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 나머지를 연산할 수 있다. That is, in the present exemplary embodiment, since the bits included in the sum result of the first adder 40 are simply checked without any complicated calculation process, the magnitudes of the first and second integers may be easily determined. The remainder of the result of subtracting an integer and a second integer divided by a decimal number can be calculated.
그리고, 제1정수가 제2정수 이상인 것으로 판단되면 제1덧셈부(40)의 합산 결과에 포함된 n비트의 이진수를, 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 나머지로 결정할 수 있다.If it is determined that the first integer is greater than or equal to the second integer, the n-bit binary number included in the sum result of the first adder 40 may be determined as the remainder obtained by dividing the subtraction result of the first and second integers by a fraction. have.
반면, 제1정수가 제2정수 미만인 것으로 판단되면 제3덧셈부(60)의 합산 결과에 포함된 n비트의 이진수를 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 나머지로 결정할 수 있다.On the other hand, if it is determined that the first integer is less than the second integer, n-bit binary numbers included in the summation result of the third adder 60 may be determined as the remainder obtained by dividing the subtraction result of the first integer and the second integer by a fraction. .
본 실시예에서는 전술한 제2이진수의 보수 처리와, 제2덧셈부(50)의 합산 결과의 보수 처리를 수행하기 위한 복수의 보수 처리부(90, 100)를 포함할 수 있다.In the present embodiment, a plurality of complementary processing units 90 and 100 for performing the above-described complementary processing of the binary number and the complementary processing of the sum result of the second adder 50 may be included.
구체적으로 제1보수 처리부(90)는 제2이진수를 보수 처리하고, 제2보수 처리부(100)는 제2덧셈부(50)의 합산 결과를 보수 처리한다.Specifically, the first repair processing unit 90 repairs the second binary number, and the second repair processing unit 100 repairs the sum result of the second adder 50.
특히, 본 실시예에 따른 제1보수 처리부(90) 및 제2보수 처리부(100)는 도 1에 도시된 바와 같이 인버터로 구성될 수 있으나 이에 한정되는 것은 아니므로 이진수를 보수 처리할 수 있는 어떠한 구성이든 포함할 수 있을 것이다.In particular, the first repair processing unit 90 and the second repair processing unit 100 according to the present embodiment may be configured as an inverter as shown in FIG. 1, but is not limited thereto. It may include any configuration.
또한 본 실시예에서는 이진수를 십진수로 변환하는 제3변환부(30) 및 연산 결과를 출력하는 출력부(80)를 더 포함할 수 있다.In addition, the present embodiment may further include a third conversion unit 30 for converting a binary number to a decimal number, and an output unit 80 for outputting an operation result.
즉, 제3변환부(30)는 제어부(70)에서 결정된 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 나머지를 사용자가 직관적으로 인식할 수 있는 십진수로 변환하고, 출력부(80)는 제3변환부(30)에서 변환되는 십진수를 출력한다.That is, the third converter 30 converts the remainder obtained by subtracting the subtraction result of the first integer and the second integer determined by the controller 70 into decimal numbers to be intuitively recognized by the user, and outputs the output unit 80. Outputs a decimal number converted by the third conversion unit 30.
도 2는 본 발명의 일 실시예에 따른 나머지를 연산하는 방법의 구현 과정을 설명하는 절차 흐름도이다.2 is a flowchart illustrating an implementation process of a method of calculating a remainder according to an embodiment of the present invention.
도 2를 참조하여 본 발명의 일 실시예에 따른 나머지를 연산하는 방법의 구현 과정을 살펴보면, 먼저 제1변환부(10)와 제2변환부(20)는 제1정수와 제2정수를 입력받아 각각 n비트의 제1이진수와 제2이진수로 변환한다(S10).Looking at the implementation process of the method for calculating the remainder according to an embodiment of the present invention with reference to Figure 2, first, the first transform unit 10 and the second transform unit 20 inputs the first integer and the second integer The first binary number and the second binary number are respectively converted into n bits (S10).
그리고 제1덧셈부(40)는 제1보수 처리부(90)를 통해 제2이진수를 보수 처리한 이진수와, 제1이진수 및 1을 합산한다(S20).In addition, the first adder 40 adds the first binary number and the first binary number to which the second binary number is repaired through the first complement processing unit 90 (S20).
이어서 제2덧셈부(50)는 제2이진수와 미리 설정된 기준정수(t)를 합산하고(S30), 제3덧셈부(60)는 제2보수 처리부(100)를 통해 제2덧셈부(50)의 합산 결과를 보수 처리한 이진수와 제1이진수 및 1을 합산한다(S40).Subsequently, the second adder 50 adds the second binary number and the predetermined reference constant t (S30), and the third adder 60 passes through the second maintenance processor 100 to add the second adder 50. In step S40, the binary number, the first binary number, and 1, which are complemented with the summation result, are added.
다음으로, 제어부(70)는 제1정수와 제2정수의 대소에 기초하여(S50) 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 나머지를 결정한다.Next, the controller 70 determines the remainder obtained by dividing the subtraction result of the first integer and the second integer by a decimal number based on the magnitude of the first integer and the second integer (S50).
전술한 바와 같이, 본 실시예에서는 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 나머지를 병렬로 위치하는 별개의 덧셈부(40 내지 60)를 통해서 연산(S20 내지 S40)하기 때문에, 제1정수와 제2정수의 대소 관계만을 알 수 있으면 그에 해당하는 합산 결과가 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 나머지인 것으로 결정할 수 있다.As described above, in the present embodiment, since the result of subtracting the result of subtraction of the first integer and the second integer is divided by a decimal number, the operation is performed through separate adders 40 to 60, which are placed in parallel (S20 to S40). If only the magnitude relationship between the first integer and the second integer is known, the corresponding summation result can be determined to be the remainder of the subtraction of the first and second integers divided by the decimal.
구체적으로 제1정수가 제2정수 이상이면 제어부(70)는 제1덧셈부(40)의 합산 결과에 포함된 n비트의 이진수를, 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 나머지로 결정한다(S60).Specifically, if the first integer is greater than or equal to the second integer, the control unit 70 divides the n-bit binary number included in the sum result of the first adder 40 by dividing the result of subtracting the first integer from the second integer by a decimal number. Determine (S60).
반면 제1정수가 제2정수 미만이면 제어부(70)는 제3덧셈부(60)의 합산 결과에 포함된 n비트의 이진수를, 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 나머지로 결정한다(S62).On the other hand, if the first integer is less than the second integer, the control unit 70 divides the n-bit binary number included in the sum result of the third adder 60 by dividing the subtraction result of the first integer and the second integer by a fraction. Determine (S62).
이와 같이 본 실시예에서는 제1정수와 제2정수의 대소 관계에 따라 서로 다른 방식으로 간단한 연산을 수행하고, 제1정수와 제2정수의 대소 관계를 반영하여 어떠한 연산 결과가 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 나머지인지 결정한다.As described above, in the present embodiment, a simple operation is performed in a different manner according to the magnitude relationship between the first integer and the second integer, and any operation result is reflected by the magnitude relationship between the first integer and the second integer. Determines whether two integer subtraction results are divided by decimals.
이어서 제3변환부(30)는 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 나머지로 결정되는 이진수를 십진수로 변환하고(S70), 출력부(80)는 변환되는 십진수를 출력하여 사용자가 제1정수와 제2정수의 차를 소수로 나눈 나머지를 간단하게 확인할 수 있도록 한다.Subsequently, the third conversion unit 30 converts the binary number determined by dividing the subtraction result of the first integer and the second integer into decimals (S70), and the output unit 80 outputs the converted decimal number to the user. Lets simply check the remainder of the difference between the first integer and the second integer divided by a decimal number.
본 실시예에 따르면, 두 정수의 대소 관계와 무관하게 복수의 덧셈부를 통해서 두 정수의 뺄셈 결과를 소수로 나눈 나머지를 연산하고, 나중에 두 정수의 대소 관계에 따라 두 정수의 뺄셈 결과를 소수로 나눈 나머지를 결정함으로써 보다 빠르게 나머지를 연산할 수 있다.According to the present exemplary embodiment, the remainder obtained by subtracting the result of subtraction of two integers through a plurality of adders regardless of the magnitude relationship of two integers, and later subtracting the result of subtraction of two integers by a decimal number according to the magnitude relationship of two integers By determining the remainder, we can compute the remainder faster.
또한 본 실시예는 합산 결과에 포함된 최상위 비트를 확인하는 방식으로 간단하게 두 정수의 대소 관계를 판단할 수 있다.In addition, the present embodiment can simply determine the magnitude relationship of two integers by checking the most significant bit included in the sum result.
본 발명은 도면에 도시된 실시예를 참고로 하여 설명되었으나, 이는 예시적인 것에 불과하며 당해 기술이 속하는 기술분야에서 통상의 지식을 가진 자라면 이로부터 다양한 변형 및 균등한 타 실시예가 가능하다는 점을 이해할 것이다. 따라서, 본 발명의 진정한 기술적 보호범위는 아래의 특허청구범위에 의하여 정해져야 할 것이다.Although the present invention has been described with reference to the embodiments shown in the drawings, it is merely exemplary and various modifications and equivalent other embodiments are possible to those skilled in the art. I will understand. Therefore, the true technical protection scope of the present invention will be defined by the claims below.

Claims (11)

  1. 두 정수의 뺄셈 결과를 소수(Prime number)로 나눈 나머지를 연산하는 장치에 있어서,In the device for calculating the remainder of the result of subtracting two integers divided by the prime number,
    제1정수와 제2정수를 입력받아 각각 n비트의 제1이진수와 제2이진수로 변환하는 제1변환부, 제2변환부;A first converting unit and a second converting unit which receive the first integer and the second integer and convert the first integer and the second binary into n bits, respectively;
    상기 제2이진수를 보수 처리한 이진수와 상기 제1이진수 및 1을 합산하는 제1덧셈부;A first adder configured to add the first binary number and the first binary number to which the second binary number is complemented;
    상기 제2이진수와 상기 소수에 대응하여 결정되는 기준정수를 합산하는 제2덧셈부;A second adder configured to add the second binary number and a reference integer determined corresponding to the decimal number;
    상기 제2덧셈부의 합산 결과를 보수 처리한 이진수와 상기 제1이진수 및 1을 합산하는 제3덧셈부; 및A third adder configured to add the first binary number and the first binary number to which the complementary result of the sum of the second adder is processed; And
    상기 제1정수와 제2정수의 대소에 기초하여 상기 제1덧셈부의 합산 결과 또는 상기 제3덧셈부의 합산 결과 중 하나를 선택하되, 상기 제1정수가 상기 제2정수 이상이면 상기 제1덧셈부의 합산 결과에 포함된 n비트의 이진수를, 상기 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 나머지로 결정하는 제어부Based on the magnitude of the first integer and the second integer, one of the sum result of the first adder or the sum result of the third adder is selected, and if the first integer is greater than or equal to the second integer, the first adder Control unit for determining the n-bit binary number included in the sum result as the remainder of the result of subtraction of the first integer and the second integer divided by a decimal number
    를 포함하는 나머지를 연산하는 장치.Apparatus for calculating the remainder comprising a.
  2. 제 1항에 있어서,The method of claim 1,
    상기 제2이진수를 보수 처리하는 제1보수 처리부와 상기 제2덧셈부의 합산 결과를 보수 처리하는 제2보수 처리부를 더 포함하는 것을 특징으로 하는 나머지를 연산하는 장치.And a second maintenance processor configured to perform a complement processing of the sum result of the first complement processing unit and the second adder to perform the complement processing on the second binary number.
  3. 제 1항에 있어서,The method of claim 1,
    상기 기준정수는 상기 소수를 2n - t로 표현했을 때 t로 설정되는 것을 특징으로 하는 나머지를 연산하는 장치.And the reference constant is set to t when the decimal number is represented by 2 n -t.
  4. 제 1항에 있어서,The method of claim 1,
    상기 제어부는 상기 제1정수가 상기 제2정수 미만이면 상기 제3덧셈부의 합산 결과에 포함된 n비트의 이진수를 상기 제1정수와 제2정수의 차를 소수로 나눈 나머지로 결정하는 것을 특징으로 하는 나머지를 연산하는 장치.The control unit determines that, when the first integer is less than the second integer, the n-bit binary number included in the sum result of the third addition unit is determined by dividing the difference between the first integer and the second integer by a decimal number. Device that calculates the remainder.
  5. 제 1항에 있어서,The method of claim 1,
    상기 제어부는 상기 제1덧셈부의 합산 결과에 포함된 (n+1)번째 비트가 1이면 상기 제1정수가 상기 제2정수 이상인 것으로 판단하고, 상기 합산 결과에 포함된 (n+1)번째 비트가 0이면 상기 제1정수가 상기 제2정수 미만인 것으로 판단하는 것을 특징으로 하는 나머지를 연산하는 장치.The controller determines that the first integer is greater than or equal to the second integer when the (n + 1) th bit included in the sum of the first adder is 1, and the (n + 1) th bit included in the sum result. Is 0, the first integer is determined to be less than the second integer.
  6. 제 1항에 있어서,The method of claim 1,
    상기 제어부에 의해 상기 제1정수와 제2정수의 차를 소수로 나눈 나머지로 결정되는 이진수를 십진수로 변환하는 제3변환부; 및A third converter converting the binary number determined by the control unit to the remainder by dividing the difference between the first integer and the second integer by a decimal number; And
    상기 제3변환부에서 변환되는 십진수를 출력하는 출력부An output unit for outputting a decimal number converted by the third conversion unit
    를 더 포함하는 것을 특징으로 하는 나머지를 연산하는 장치.Apparatus for calculating the remainder further comprises.
  7. 두 정수의 뺄셈 결과를 소수(Prime number)로 나눈 나머지를 연산하는 방법에 있어서,In the method of calculating the remainder of the result of subtracting two integers divided by a prime number,
    제1변환부와 제2변환부가 제1정수와 제2정수를 입력받아 각각 n비트의 제1이진수와 제2이진수로 변환하는 단계;A first converting unit and a second converting unit receiving the first integer and the second integer and converting the first binary number and the second binary number to n bits, respectively;
    제1덧셈부가 상기 제2이진수를 보수 처리한 이진수와 상기 제1이진수 및 1을 합산하는 단계;Adding a first binary addition and a complementary binary number by the first addition unit to the first binary number and 1;
    제2덧셈부가 상기 제2이진수와 상기 소수에 대응하여 결정되는 기준정수를 합산하는 단계;Summing a second integer and a reference integer determined in correspondence with the decimal part;
    제3덧셈부가 상기 제2덧셈부의 합산 결과를 보수 처리한 이진수와 상기 제1이진수 및 1을 합산하는 단계; 및Adding a third binary addition-complementary binary number, the first binary number and the first one, of which the complementary result of the second addition unit is added; And
    제어부가 상기 제1정수와 제2정수의 대소에 기초하여 상기 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 결과를 결정하는 단계를 포함하되, 상기 제어부는 상기 제1정수가 상기 제2정수 이상이면 상기 제1덧셈부의 합산 결과에 포함된 n비트의 이진수를, 상기 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 나머지로 결정하는 것을 특징으로 하는 나머지를 연산하는 방법.And determining, by the controller, a result of dividing the subtraction result of the first integer and the second integer by a decimal number based on the magnitude of the first integer and the second integer, wherein the controller is configured to determine the first integer as the second integer. And if it is an integer or more, determine the n-bit binary number included in the sum result of the first adder as the remainder obtained by dividing the subtraction result of the first and second integers by a fraction.
  8. 제 7항에 있어서,The method of claim 7, wherein
    상기 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 결과를 결정하는 단계에서, 상기 제어부는 상기 제1정수가 상기 제2정수 미만이면 상기 제3덧셈부의 합산 결과에 포함된 n비트의 이진수를 상기 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 나머지로 결정하는 것을 특징으로 하는 나머지를 연산하는 방법.In the determining of a result of dividing the subtraction result of the first integer and the second integer by a fraction, the control unit, when the first integer is less than the second integer, n-bit binary number included in the sum result of the third adder And subtracting the result of the subtraction of the first integer and the second integer into a remainder divided by a decimal number.
  9. 제 7항에 있어서,The method of claim 7, wherein
    상기 제2이진수와 상기 소수에 대응하여 결정되는 기준정수를 합산하는 단계에서, 상기 기준정수는 상기 소수를 2n - t로 표현했을 때 t로 설정되는 것을 특징으로 하는 나머지를 연산하는 방법.In the step of summing the second binary number and the reference constant determined corresponding to the decimal, wherein the reference constant is set to t when the decimal is represented by 2 n -t.
  10. 제 7항에 있어서,The method of claim 7, wherein
    상기 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 나머지를 결정하는 단계에서, 상기 제어부는 상기 제1덧셈부의 합산 결과에 포함된 (n+1)번째 비트가 1이면 상기 제1정수가 상기 제2정수 이상인 것으로 판단하고, 상기 합산 결과에 포함된 (n+1)번째 비트가 0이면 상기 제1정수가 상기 제2정수 미만인 것으로 판단하는 것을 특징으로 하는 나머지를 연산하는 방법.In the determining of the remainder obtained by dividing the subtraction result of the first integer and the second integer by a decimal number, the controller determines that the first integer is equal to (n + 1) th bit included in the sum result of the first adder; And determining that the second integer is equal to or greater than the second integer, and determining that the first integer is less than the second integer when the (n + 1) th bit included in the sum result is 0.
  11. 제 1항에 있어서,The method of claim 1,
    상기 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 나머지를 결정한 이후에, 제3변환부가 상기 제1정수와 제2정수의 뺄셈 결과를 소수로 나눈 나머지로 결정되는 이진수를 십진수로 변환하는 단계; 및After determining the remainder by dividing the subtraction result of the first integer and the second integer by a decimal number, the third conversion unit converts the binary number determined by dividing the subtraction result of the first integer and the second integer by a decimal number to a decimal number. step; And
    출력부가 상기 변환되는 십진수를 출력하는 단계Outputting the converted decimal number by the output unit
    를 더 포함하는 것을 특징으로 하는 나머지를 연산하는 방법.Method for calculating the remainder further comprises.
PCT/KR2014/010326 2014-09-24 2014-10-31 Apparatus and method for calculating remainder WO2016047848A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
KR1020140127788A KR20160035882A (en) 2014-09-24 2014-09-24 Apparatus for calculating remainder and method thereof
KR10-2014-0127788 2014-09-24

Publications (1)

Publication Number Publication Date
WO2016047848A1 true WO2016047848A1 (en) 2016-03-31

Family

ID=55581357

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/KR2014/010326 WO2016047848A1 (en) 2014-09-24 2014-10-31 Apparatus and method for calculating remainder

Country Status (2)

Country Link
KR (1) KR20160035882A (en)
WO (1) WO2016047848A1 (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR970059919A (en) * 1996-01-17 1997-08-12 김광호 Remaining calculation method and circuit
JPH1195982A (en) * 1997-06-23 1999-04-09 Sun Microsyst Inc Circuit, method and system for arithmetic processing
KR20010014992A (en) * 1999-06-04 2001-02-26 이데이 노부유끼 Divider and method with high radix
US20120158812A1 (en) * 2010-12-15 2012-06-21 International Business Machines Corporation Parallel computation of a remainder by division of a sequence of bytes

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR970059919A (en) * 1996-01-17 1997-08-12 김광호 Remaining calculation method and circuit
JPH1195982A (en) * 1997-06-23 1999-04-09 Sun Microsyst Inc Circuit, method and system for arithmetic processing
KR20010014992A (en) * 1999-06-04 2001-02-26 이데이 노부유끼 Divider and method with high radix
US20120158812A1 (en) * 2010-12-15 2012-06-21 International Business Machines Corporation Parallel computation of a remainder by division of a sequence of bytes

Also Published As

Publication number Publication date
KR20160035882A (en) 2016-04-01

Similar Documents

Publication Publication Date Title
EP4080351A1 (en) Arithmetic logic unit, and floating-point number multiplication calculation method and device
US20160291934A1 (en) Floating-point adder circuitry
JPH02294820A (en) Floating point arithmetic processor and arithmetic processing
CN117111881B (en) Mixed precision multiply-add operator supporting multiple inputs and multiple formats
CN108055041B (en) Data type conversion circuit unit and device
US20240020094A1 (en) Multiplication-accumulation system, multiplication-accumulation method, and electronic device
CN111381808B (en) Multiplier, data processing method, chip and electronic equipment
WO2016047848A1 (en) Apparatus and method for calculating remainder
CN113625989B (en) Data operation device, method, electronic device, and storage medium
TW202044017A (en) Multi-input floating-point adder
WO2023113445A1 (en) Method and apparatus for floating point arithmetic
KR0146656B1 (en) Multi-nary or logic device
JPH0511980A (en) Overflow detecting method and circuit
JPH0540605A (en) Floating point multiplier
WO2017007044A1 (en) Signal processing device and method
JPH1091396A (en) Floating-point number detection device and circuit
US7469265B2 (en) Methods and apparatus for performing multi-value range checks
Gonzalez-Navarro et al. A binary integer decimal-based multiplier for decimal floating-point arithmetic
Drusya et al. Area efficient fused floating point three term adder
JPS5960637A (en) Arithmetic device for floating decimal point
WO2013081484A1 (en) Unified computation systems and methods for iterative multiplication and division
JPS63158626A (en) Arithmetic processing unit
JPH0635671A (en) Floating point adder-subtracter
KR100403194B1 (en) Multiplier
JPH04213110A (en) Method and apparatus for floating-point arithmetic operation

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 14902712

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 14902712

Country of ref document: EP

Kind code of ref document: A1