JPH03185516A - Method for converting decimal number into binary number - Google Patents
Method for converting decimal number into binary numberInfo
- Publication number
- JPH03185516A JPH03185516A JP1324454A JP32445489A JPH03185516A JP H03185516 A JPH03185516 A JP H03185516A JP 1324454 A JP1324454 A JP 1324454A JP 32445489 A JP32445489 A JP 32445489A JP H03185516 A JPH03185516 A JP H03185516A
- Authority
- JP
- Japan
- Prior art keywords
- binary
- converted
- decimal
- value
- binary number
- Prior art date
- Legal status (The legal status 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 status listed.)
- Pending
Links
Abstract
Description
【発明の詳細な説明】
〔概 要〕
レジスタ1個分の値を持つ10進数を2進数に変換でき
る2進数化処理部を用いて、レジスタ1個分の値よりも
大きい値を持つ10進数を2進数に変換する方法に関し
。[Detailed Description of the Invention] [Summary] A decimal number with a value larger than the value of one register is created using a binary processing unit that can convert a decimal number with the value of one register into a binary number. Regarding how to convert into binary numbers.
指定できる10進数の桁数についての制限を除去し、い
かなる桁数の10進数をも2進数に変換できるようにす
ることを目的とし。The purpose is to remove restrictions on the number of decimal digits that can be specified, and to make it possible to convert decimal numbers of any number of digits into binary numbers.
変換の対象である10進数を、上記2進数化処環部によ
って2進数に変換可能な桁数の複数の数字列に分割し、
それぞれの分割された数字列について10進数とみなし
て2進数に変換された後に対応する変換前の数字列が当
該変換の対象である10進数において持っていた重みを
掛は算して。Divide the decimal number to be converted into a plurality of number strings with a number of digits that can be converted into binary numbers by the binary number processing ring,
After each divided number string is treated as a decimal number and converted into a binary number, the weight that the corresponding number string before conversion had in the decimal number to be converted is calculated.
これらの重みを掛は算された2進数をすべて加算するこ
とによって当該変換の対象である10進数を2進数に変
換するように構成する。By multiplying these weights and adding all the calculated binary numbers, the decimal number that is the object of the conversion is converted into a binary number.
本発明は、レジスタ1個分の値を持つ10進数を2進数
に変換できる2進数化処理部を用いて。The present invention uses a binary number processing unit that can convert a decimal number having the value of one register into a binary number.
レジスタ1個分の値よりも大きい値を持つ10進数を2
進数に変換する方法に関する。2 decimal numbers with a value greater than the value of one register
Concerning how to convert to base numbers.
従来、レジスタ1個分の値を持つlO進敗を2進数に変
換できる2進数化処理部を用いて、レジスタ1個分の値
よりも大きい値を持つ10進数を2進数に変換すること
はできなかった。Conventionally, it has been impossible to convert a decimal number that has a value larger than the value of one register into a binary number using a binary number processing unit that can convert a decimal number that has the value of one register into a binary number. could not.
〔発明が解決しようとする課題〕
従って、言語で指定できる10進数にはIIIIIがあ
り1例えば、レジスタ1個の容量が4バイトの場合には
、値21−1よりも大きな10進数の値を指定すること
はできなかった。[Problem to be solved by the invention] Therefore, there are three decimal numbers that can be specified in a language.For example, if the capacity of one register is 4 bytes, a decimal value larger than the value 21-1 can be specified. It was not possible to specify.
本発明は、指定できる10進数の桁数についての制限を
除去し、いかなる桁数の10進数をも2進数に変換でき
るようにすることを目的とする。An object of the present invention is to remove restrictions on the number of digits of a decimal number that can be specified, and to make it possible to convert a decimal number of any number of digits into a binary number.
第1図は9本発明の原理構成図である0図中。 FIG. 1 is a diagram showing the principle configuration of the present invention.
符号20は分割処理部、30は2進数化処理部。Reference numeral 20 represents a division processing unit, and 30 represents a binary number processing unit.
40は乗算処理部、50は加算処理部を示している。Reference numeral 40 indicates a multiplication processing section, and 50 indicates an addition processing section.
分割処理部20は、変換の対象である10進数を構成す
る数字の列を、その数字の並び順を変えずに、上記2進
数化処理部30で変換可能な桁数以下の個数の数字から
威る数字列A1ないしA。The division processing unit 20 divides the sequence of numbers constituting the decimal number to be converted from numbers whose number is less than or equal to the number of digits that can be converted by the binary number processing unit 30 without changing the order of the numbers. The intimidating number string A1 to A.
に分割する。Divide into.
2進数化処理部30は、上記のそれぞれの数字列A1を
独立した10進数とみなして2進数Aコに変換する。The binary number processing unit 30 regards each of the above-mentioned number strings A1 as independent decimal numbers and converts them into binary numbers A.
乗算処理部40は、上記変換によって得られたそれぞれ
の2進数に直について、・対応する上記変換前の数字列
Atの最下位が、上記変換の対象であるlO道数におい
て下からmi桁目であった場合には、当該2進数Aコに
数値10をm、−1回乗する処理を実行する。For each binary number obtained by the above conversion, the multiplication processing unit 40 calculates that the lowest order of the corresponding number string At before the conversion is the mi digit from the bottom in the lO path number that is the object of the above conversion. If so, a process is executed in which the binary number A is multiplied by the numerical value 10 m, -1 times.
加算処理部50は、上記乗算処理部40によって乗算処
理をなされた2進数をすべて加算する。The addition processing section 50 adds all the binary numbers that have been multiplied by the multiplication processing section 40.
変換の対象である10進数は1分割処理部20によって
複数の数字列A、ないしA5に分割される。The decimal number to be converted is divided into a plurality of number strings A to A5 by the 1-division processing unit 20.
次に9それぞれの数字列AIは2進数化処理部30によ
って2進数に変換可能な桁数になっているので、2進数
Aコにf:換される。Next, since the number string AI of 9 has a number of digits that can be converted into a binary number by the binary number processing unit 30, it is converted into a binary number A.
続いて、各2道数Aコについて、対応する変換前の数字
列A+が当該変換対象の10進数において持っていた重
みを掛は算される。Next, for each two-way number A, the weight that the corresponding number string A+ before conversion had in the decimal number to be converted is calculated.
最後に上記重みを掛は算された2進数をすべて加算する
ことによって、当該変換対象である10進数を2進数に
変換した値が求められる。Finally, by multiplying the above weights and adding all the calculated binary numbers, a value obtained by converting the decimal number to be converted into a binary number is obtained.
第2図は処理概要図、第3図は処理■のフローチャート
を示している。FIG. 2 shows a process outline diagram, and FIG. 3 shows a flowchart of process (2).
第2図に示す如く以下の処理を進行する。The following processing proceeds as shown in FIG.
処理■では、Xをリセットする。In process (2), X is reset.
処理■では、処理する10進数字がな(なるまで処理■
ないし処理■を繰り返す。In Process■, process until the decimal digit to be processed becomes
or repeat process ■.
処理■では、変換対象である10進数を構成する数字の
列から、1度に2進数に変換することができる桁数以下
の個数の数から威る数字列を取り出す、但し、1度取り
出された数字を再び取り出すことはしない。In process 2, a string of numbers is extracted from the string of numbers that make up the decimal number to be converted, the number of digits being less than or equal to the number of digits that can be converted into a binary number at one time. It does not retrieve the numbers again.
処理■では、処理■で取り出した数字列を2進数に変換
して10″−’を乗じる。ここで1mは処理Oで取り出
された数字列の最下位が変換の対象である元の10進数
において下から何桁目であったかを示す値である。In process ■, the number string extracted in process ■ is converted into a binary number and multiplied by 10''-'.Here, 1m is the original decimal number whose lowest digit in the number string extracted in process O is the target of conversion. This is the value indicating the number of digits from the bottom.
処理■では、処理■で得られた値をXに加える。In process (2), the value obtained in process (2) is added to X.
演算終了時に当該Xが答となる。At the end of the calculation, the corresponding X becomes the answer.
第3図は処理■の詳細フローチャートを示す。FIG. 3 shows a detailed flowchart of process (2).
処理[相]では、処理■で取り出した数字列を独立した
10進数とみなして2進数に変換する。In the process [phase], the number string extracted in the process (2) is regarded as an independent decimal number and converted into a binary number.
処理0ではV、をリセントする。ここでは、レジスタ2
個分の領域をVとして、その先頭レジスタ1個分の領域
をv7.下位レジスタ1個分の領域をvtとする。In process 0, V is re-centered. Here, register 2
The area for one register is V7. Let vt be the area for one lower register.
処理Oでは、■、に処理[相]で得られた値を代入する
。In process O, the value obtained in process [phase] is substituted for .
処理[相]では、処理[株]ないし処理[相]をm−1
回繰り返す、但しMとNとをレジスタ2個分の領域とし
、それぞれの先頭レジスタ1個分の領域をMNl、下位
のレジスタ1個分の領域をMz 、 Ntとする。In the treatment [phase], the treatment [strain] or treatment [phase] is m−1.
However, let M and N be areas for two registers, let MNl be the area for one leading register, and Mz and Nt be areas for one lower register.
処理[相]では、■1を10倍したものをMに代入する
。In the process [phase], (1) multiplied by 10 is substituted into M.
処理[相]では、v3を10倍したものをNに代入する
。In the process [phase], v3 multiplied by 10 is assigned to N.
処理0では9M8にN、を足したものをV、に代入する
。In process 0, the sum of 9M8 and N is assigned to V.
処理[相]では、N、をV、に代入する。In the process [phase], N, is substituted into V,.
処理[相]では、■に求める値が入っているので。In the process [phase], ■ contains the desired value.
■の値を処理■へ送る。Send the value of ■ to processing ■.
例として、10進数 12345678901 を第2図に示した処理によって2進数に変換する。As an example, decimal number 12345678901 is converted into a binary number by the process shown in FIG.
但し、レジスタ1個の容量を4バイトとする。However, the capacity of one register is 4 bytes.
i)2進数化できる最大値が
2”−1=2147483647
であるとすると、9桁以下の10進数ならば必ず2進数
に変換できる。よって処理■では上位桁から9桁分の数
字列
123456789
を取り出す。i) Assuming that the maximum value that can be converted into a binary number is 2" - 1 = 2147483647, any decimal number with 9 digits or less can always be converted into a binary number. Therefore, in process Take it out.
ii)処理■では、上記取り出した数字列を10進数と
みなして2進数に変換して
(075B(:D15)+4を得て、この値に10!を
乗する。102とした理由は、当該取り出した数字列の
最下位が元の10進数において、下から3桁目だからで
ある。その結果は。ii) In process (■), consider the extracted number string as a decimal number, convert it to a binary number, obtain (075B(:D15)+4, and multiply this value by 10!.The reason for setting it to 102 is that This is because the lowest digit of the extracted number string is the third digit from the bottom in the original decimal number.The result is.
(0000002DFDCIC34)I。(0000002DFDCIC34)I.
となる。becomes.
ii)上記結果をXに代入し、残りの数字列O1を取り
出して2進数に変換する。この結果は(0000000
1)、
である。ii) Substitute the above result into X, take out the remaining number string O1, and convert it into a binary number. This result is (0000000
1).
1V)ii)の結果と1+ )の結果を加えると、その
結果
(00000002DFDCIC35)l。Adding the result of 1V) ii) and the result of 1+), the result is (00000002DFDCIC35)l.
が得られる。is obtained.
なお、ここでは例としてVをレジスタ2個分としたので
、2進数に変換できる10進数はレジスタ2個分に制限
されるが、■の容量を増加すれば更に大きな10進数に
ついても2進数に変換でき(発明の効果)
以上説明した如く1本発明によればレジスタ1個分の値
よりも大きな値を持つ10進数であっても2進数に変換
することが可能となる。Note that here, as an example, V is the equivalent of two registers, so the decimal number that can be converted to binary is limited to the equivalent of two registers, but if you increase the capacity of ■, even larger decimal numbers can be converted to binary. Convertible (Effect of the Invention) As explained above, according to the present invention, even a decimal number having a value larger than the value of one register can be converted into a binary number.
第1図は本発明の原理構成図、第2図は処理概要図、第
3図は処理■の詳細なフローチャートを示す。
図中、20は分割処理部、30は2進数化処理部、40
は乗算処理部、50は加算処理部を表す。FIG. 1 shows a principle configuration diagram of the present invention, FIG. 2 shows a process outline diagram, and FIG. 3 shows a detailed flowchart of process (2). In the figure, 20 is a division processing section, 30 is a binary number processing section, 40
5 represents a multiplication processing section, and 50 represents an addition processing section.
Claims (1)
る2進数化処理部(30)を用いて、レジスタ1個分の
値よりも大きい値を持つ10進数を2進数に変換する方
法において、 変換の対象である10進数を構成する数字の列を、その
数字の並び順を変えずに、上記2進数化処理、で変換可
能な桁数以下の個数の数字から成る複数の数字列(A_
1ないしA_k)に分割し、上記分割されたそれぞれの
数字列(A_i)を独立した10進数とみなして2進数
(A’_i)に変換し、 上記変換によって得られたそれぞれの2進数(A’_i
)について、対応する上記変換前の数字列(A_i)の
最下位が、上記変換の対象である10進数において、下
からm_i桁目であった場合には、当該変換によって得
られた2進数(A’_i)に数値10をm_i−1回乗
ずる乗算処理を実行し、上記乗算処理をされたそれぞれ
の2進数がすべて加算されるようにする ことによって当該変換の対象である10進数を2進数に
変換した値を求めるようにした ことを特徴とする10進数を2進数に変換する方法。[Claims] Using a binary number processing unit (30) capable of converting a decimal number having a value for one register into a binary number, a decimal number having a value larger than the value for one register is converted into a binary number. In the method of converting to a base number, the sequence of numbers that make up the decimal number to be converted is converted from a number of digits that is less than or equal to the number of digits that can be converted by the above binary conversion process, without changing the order of the numbers. Multiple number strings consisting of (A_
1 to A_k), each of the divided number strings (A_i) is treated as an independent decimal number and converted to a binary number (A'_i), and each binary number (A_i) obtained by the above conversion is '_i
), if the lowest point of the corresponding number string (A_i) before conversion is the m_i digit from the bottom in the decimal number to be converted, then the binary number (A_i) obtained by the conversion is A'_i) is multiplied by the numerical value 10 m_i-1 times, and all the binary numbers subjected to the above multiplication processing are added, thereby converting the decimal number that is the target of the conversion into a binary number. A method for converting a decimal number into a binary number, characterized in that a value converted into a value is obtained.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP1324454A JPH03185516A (en) | 1989-12-14 | 1989-12-14 | Method for converting decimal number into binary number |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP1324454A JPH03185516A (en) | 1989-12-14 | 1989-12-14 | Method for converting decimal number into binary number |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| JPH03185516A true JPH03185516A (en) | 1991-08-13 |
Family
ID=18165991
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP1324454A Pending JPH03185516A (en) | 1989-12-14 | 1989-12-14 | Method for converting decimal number into binary number |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JPH03185516A (en) |
Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JPS4834332A (en) * | 1971-09-06 | 1973-05-18 | ||
| JPS6083140A (en) * | 1983-10-14 | 1985-05-11 | Hitachi Ltd | multiplier |
| JPS6115233A (en) * | 1984-06-30 | 1986-01-23 | Sony Corp | Multiplier |
-
1989
- 1989-12-14 JP JP1324454A patent/JPH03185516A/en active Pending
Patent Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JPS4834332A (en) * | 1971-09-06 | 1973-05-18 | ||
| JPS6083140A (en) * | 1983-10-14 | 1985-05-11 | Hitachi Ltd | multiplier |
| JPS6115233A (en) * | 1984-06-30 | 1986-01-23 | Sony Corp | Multiplier |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| GB2039393A (en) | Digital multipliers | |
| EP0442356A2 (en) | Weighted-delay column adder and method of organizing same | |
| US5142490A (en) | Multiplication circuit with storing means | |
| US4837791A (en) | Counter | |
| US6546411B1 (en) | High-speed radix 100 parallel adder | |
| JP2682142B2 (en) | Multiplier | |
| JPH05173761A (en) | Binary integer multiplier | |
| SU1751856A1 (en) | Code converter | |
| SU1501277A1 (en) | Binary to binary-decimal code converter | |
| RU2021633C1 (en) | Multiplying device | |
| JP2820701B2 (en) | Conversion method to binary | |
| SU809153A1 (en) | Device for bcd-to-binary conversion | |
| SU849198A1 (en) | Reversive binary-to-bcd code converter | |
| RU2001428C1 (en) | Adding device | |
| SU436345A1 (en) | CODE CONVERTER | |
| JPH01314020A (en) | Decimal/binary conversion system | |
| SU1160290A1 (en) | Method of registering spectroelectron paramagnetic resonance | |
| SU868747A1 (en) | Binary-to-decimal code converter | |
| SU860055A1 (en) | Converter of bcd numbers in 4,2,2,1 code to binary numbers | |
| JPH01267727A (en) | Multiplier for processing signal | |
| SU1721601A1 (en) | Serial k-@@ adder | |
| GB2067799A (en) | Improvements in or Relating to Digital Filters | |
| SU932489A1 (en) | Binary number multiplying device | |
| SU714395A1 (en) | Arrangement for sped-up multiplication | |
| SU888104A1 (en) | Binary-coded-decimal-to-binary code converter |