CN111831253A - Processing method for super-long digit subtraction and computer readable storage medium - Google Patents

Processing method for super-long digit subtraction and computer readable storage medium Download PDF

Info

Publication number
CN111831253A
CN111831253A CN202010618103.XA CN202010618103A CN111831253A CN 111831253 A CN111831253 A CN 111831253A CN 202010618103 A CN202010618103 A CN 202010618103A CN 111831253 A CN111831253 A CN 111831253A
Authority
CN
China
Prior art keywords
super
subtraction
long
level
digit
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
Application number
CN202010618103.XA
Other languages
Chinese (zh)
Inventor
戚建淮
郑伟范
汪乔
刘建辉
韩丹丹
唐娟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Y&D Electronics Information Co Ltd
Original Assignee
Shenzhen Y&D Electronics Information Co Ltd
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 Shenzhen Y&D Electronics Information Co Ltd filed Critical Shenzhen Y&D Electronics Information Co Ltd
Priority to CN202010618103.XA priority Critical patent/CN111831253A/en
Publication of CN111831253A publication Critical patent/CN111831253A/en
Pending legal-status Critical Current

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
    • G06F7/50Adding; Subtracting

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Computational Mathematics (AREA)
  • Mathematical Analysis (AREA)
  • Pure & Applied Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computing Systems (AREA)
  • Mathematical Optimization (AREA)
  • General Engineering & Computer Science (AREA)
  • Compression, Expansion, Code Conversion, And Decoders (AREA)

Abstract

The invention relates to a processing method of super-long digit subtraction, which comprises the following steps: s1, coding the super-long digit number based on the coding mode and the base number of the calculation system to generate a hierarchical super-long digit number code; and S2, carrying out subtraction operation according to the sign of the super-long digit participating in the super-long digit subtraction and the super-long digit code generated by the super-long digit. The invention also relates to a computer-readable storage medium. By implementing the processing method and the computer readable storage medium for super-long digit subtraction, the coding symbol extraction is carried out on a super-long digit N, then the coding level and the level base number corresponding to each level are calculated, so that the coding method for super-long digits exceeding the current computer function processing digit is provided, and further, the subtraction calculation method based on super-long digit coding is provided, so that super-fast subtraction operation of super-large numerical values can be realized, and the requirements of large computing tasks such as large data analysis, processing, calculation and the like are met.

Description

Processing method for super-long digit subtraction and computer readable storage medium
Technical Field
The present invention relates to the field of information encoding and calculation, and more particularly, to a processing method and a computer-readable storage medium for super-long bit subtraction.
Background
Large number operations, as the name implies, are a series of operations performed on a large number of values. It is known that there is no upper limit to the magnitude of a numerical value in mathematics, but in computers, the range that can be expressed by a computer is limited due to the word length limitation, and when we operate on a relatively small number, such a numerical value does not exceed the expression range of the computer, so that the operation can be performed. However, when we perform a large amount of data processing in practical applications, the range of values represented by the basic data types provided by the programming language is limited, and large-scale high-precision numerical calculation cannot be satisfied.
The majority of arithmetic is widely applied in the fields of information security, digital images, big data mining and the like at present. At present, common majority algorithms comprise a simulated manual calculation algorithm, a fast Fourier transform algorithm, a Chinese remainder theorem and the like, and the algorithms generally have the problem of low efficiency.
Disclosure of Invention
The technical problem to be solved by the present invention is to provide a processing method for super-long bit number subtraction and a computer readable storage medium, which can implement super-fast subtraction of super-large number, so as to meet the needs of large computational task such as large data analysis, processing, and calculation.
The technical scheme adopted by the invention for solving the technical problems is as follows: a processing method for super-long digit subtraction is constructed, and comprises the following steps:
s1, coding the super-long digit number based on the coding mode and the base number of the calculation system to generate a hierarchical super-long digit number code;
and S2, carrying out subtraction operation according to the sign of the super-long digit participating in the super-long digit subtraction and the super-long digit code generated by the super-long digit.
In the processing method of super-long bit number subtraction according to the present invention, the step S1 further includes:
s11, adopting polynomial to change X into X for decimal super-long digit numbertXt-1……X1Expressed as X ═ X1*(10)0+X2*(10)1+……+Xt*(10)t-1T is a natural number, and the sign of X is X.bSign;
s12 traversing character string XtXt-1…X1Binary coding each character in the character string to obtain a coded character string and a first level base;
s13, traversing the code character string from the first non-zero character of the code character string, and carrying out binary coding on each character in the code character string to obtain a newly generated code character string and a next level base number; and carrying out binary coding on the newly generated coded character string obtained by each traversal until the finally generated character string is empty, and generating the hierarchical ultra-long bit number code based on the number of layers and the cardinal number of each level.
In the processing method of super-long bit number subtraction according to the present invention, the step S12 further includes:
s121, traversing the character string X as X based on the following formulatXt-1…X1Binary encoding each character in the string to obtain an encoded string and a first level base:
based on Xt→Xt/2n=α1,Xt%2n=β1,X→α1Xt-1…X1
Xt-11*10→(Xt-11*10)/2n=α2,(Xt-11*10)%2n=β2,X→α1α2Xt-2…X1
……
X1γ-1*10→(X1γ-1*10)/2n=αγ,(X1γ-1*10)%2n=βγ,X→α1α2…αγ
Wherein the code string is alpha1α2…αγThe first level cardinality is: beta is aγB, carrying out the following steps of; n represents the maximum number of digits that the computer can calculate,% represents remainder, and/represents quotient, which are all integer operations.
In the processing method of super-long bit number subtraction according to the present invention, the step S13 further includes:
s131, from the code character string alpha1α2…αγStarts with the first non-zero character of alpha1α2…αγAs X, the step S121 is performed to obtain a newly generated character string and a next level base;
s132, repeating the step S131 on the newly generated character string until the finally generated character string is empty;
s133, generating the hierarchical super-long bit number coding X ' ═ X ' based on the number of layers and the cardinality per hierarchy '1*(2n)0+X'2*(2n)1+……+X'u*(2n)u-1Wherein u represents the number of layers, X'1,X'2,……,X'uIs the base of each layer.
In the processing method of super-long bit number subtraction according to the present invention, the step S2 further includes:
s21, generating the hierarchical super long bit number coding M 'and N' based on the two super long bit numbers M and N participating in super long bit number subtraction, wherein the two super long bit numbers M and N have the same sign and the hierarchical super long bit number coding M 'is greater than the hierarchical super long bit number coding N':
M'=M′1*(2n)0+M'2*(2n)1+……+M'u*(2n)u-1u is the number of layers of the super-long digit M, M'1,M'2,……,M'uIs the base number of each layer,
N'=N′1*(2n)0+N'2*(2n)1+……+N'v*(2n)v-1v is the number of layers of the super-long digit N;
s22, taking the super-long digit codes M ' of the hierarchical levels as minuets, taking the super-long digit codes N ' of the hierarchical levels as minuets, arranging the super-long digit codes N ' of the hierarchical levels from right to left according to the hierarchical levels from low to high, calculating the intermediate subtraction difference of each hierarchical level, and carrying out binary coding on each intermediate subtraction difference to obtain borrows and subtraction result numbers of each hierarchical level;
s23, determining the subtraction result based on the subtraction result number of each level and the borrow number of each level, and determining the sign of the subtraction result number based on the signs of the super-long digit codes M 'and N' of the hierarchical levels.
In the processing method of super-long bit number subtraction according to the present invention, the step S22 further includes:
s221, arranging the hierarchical super-long digit number codes M 'and the hierarchical super-long digit number codes N' from right to left according to the hierarchy from low to high to calculate the subtraction result resMinus ═ R1,R2,……,Rt]:
Figure BDA0002562106270000041
S222, for each level, obtaining the intermediate subtraction difference of the level according to binary expansion based on the number of codes in the level, and obtaining the intermediate subtraction difference based on the intermediate subtraction difference and 2nThe borrow number and the subtraction result number of the hierarchy are calculated according to the comparison result of the step number and the subtraction result number.
In the processing method of super-long bit number subtraction according to the present invention, the step S222 further includes:
s2221, borrow number J for the first level0Calculating an intermediate subtraction difference sub for the first level 01=M′1-N′1-J0And judging the intermediate subtraction difference sub1Positive and negative of (2)When the intermediate subtraction difference sub1Positive, the number of subtraction results R of the first level1=sub1Borrow number J of the first level10; when the intermediate subtraction difference sub1Negative, the number of subtraction results R of the first level1=sub1+2nBorrow number J of the first level1=1;
S2222, for the second level to the t-1 level, repeatedly executing the step S2221 to calculate the subtraction result number and borrow number of each level;
s2223, for the t level, calculating the intermediate subtraction difference sub of the t levelt=M′t-N′t-Jt-1Setting the number of subtraction results R of the t-th levelt=subt
In the method for processing super-long digit number subtraction according to the present invention, in step S23, the subtraction result resMinus ═ R1*(2n)0+R2*(2n)1+……+Rt*(2n)t-1T is a natural number; symbol of resMinus: bsign, res minus.
In the processing method for super-long bit number subtraction according to the present invention, in step S2, the SDN controller distributes the calculation task in parallel to each child node, and each child node calculates (M'1-N′1),(M'2-N'2),……,(M′u-N′v) Then the result of the calculation (sub)1,J1),(sub2,J2),……,(subt,Jt) Returning to the SDN controller, the SND controller collects the subtraction result resMinus ═ R1,R2,……,Rt]。
Another technical solution to solve the technical problem of the present invention is to configure a computer-readable storage medium, on which a computer program is stored, wherein the computer program, when executed by a processor, implements the processing method of the super-long bit number subtraction.
Processing method and meter for super-long digit subtraction implementing the inventionComputer readable storage medium by converting a very long number of bits N (typically more than 2)64-1), extracting coding symbols, and then calculating coding levels and level base numbers corresponding to each level, thereby providing a coding method of ultra-long digits exceeding the current computer processing digits, and further providing a subtraction calculation method based on ultra-long digit coding, which can realize ultra-fast subtraction of ultra-large numerical values, thereby adapting to the needs of large-computing-force calculation tasks such as large data analysis, processing, calculation and the like.
Drawings
The invention will be further described with reference to the accompanying drawings and examples, in which:
FIG. 1 is a flow chart of a first preferred embodiment of the processing method of the super-long bit number subtraction of the present invention;
FIG. 2 is a flow diagram of a preferred embodiment of a subtraction calculation process of the processing method of super long bit number subtraction of the present invention;
FIG. 3 is a flow chart of a specific embodiment of factoring according to the Shor algorithm using the ultra-long bit number coding processing method of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The invention aims to provide a method suitable for super-long digit coding and fast subtraction calculation, which can complete the subtraction calculation of complex tasks under the existing computer system and mainly comprises more than 264The ultra-long bit coding mode and the subtraction calculation process of-1 can greatly exceed the bit number which can be processed by the current computer by the calculated data, and can realize 2nCoding of very long digits in the (n is a natural number) system, while addressing 2nAnd (5) coding the binary system ultra-long digit. The invention can carry out parallel computation from a low level to a high level by defining different levels, thereby adopting a plurality of low computationsThe capacity is expanded in a single-node parallel mode, the space is changed in time, ultra-fast ultra-large numerical calculation is achieved, and the high calculation force requirements of future large data calculation and information processing are met. The method can realize exponential-level fast subtraction calculation of the ultra-long digit, and is suitable for the requirements of large-computing-power calculation tasks such as large-data analysis, processing and calculation.
As shown in fig. 1, the processing method of the super-long bit number subtraction of the present invention is divided into two steps. In step S1, the super-long bit number is encoded based on the encoding mode and the calculation base number to generate a component level super-long bit number encoding. The encoded data structure includes: coding symbols, the number of coding levels and the corresponding hierarchical cardinality of each level. The code symbols mainly adopt true/false to represent "+" or "-" of the ultra-long digit. The coding level refers to the number of layers that can be coded by a super-long bit. The base number of the calculation system means that the base number of the calculation system of each level, namely the number N of the super-long digits is in accordance with 2nAnd (n is a natural number) carrying out hierarchical coding on the system, wherein the base number of the hierarchical calculation system is as follows: 0 to 2n-1. In the calculation process of the calculation system base numbers, a Software Defined Network (SDN) mechanism can be adopted, and the SDN manager defines the calculation system base numbers in each hierarchy in a user intelligent definition mode, namely the base numbers are flexibly defined by the software defined network mechanism according to calculation tasks and the number of parallel distribution calculation nodes. The SDN manager is an intelligent management control device for realizing an SDN mechanism.
According to the coding mode definition and the calculation system base number definition, each super-long digit participating in calculation is coded through symbolic calculation to generate codes capable of adopting parallel calculation and provide super-long digit calculation support, and the specific calculation process is as follows:
the ultra-long digit number X in decimal is: x ═ XtXt-1……X1The polynomial can be expressed as follows:
X=X1*(10)0+X2*(10)1+……+Xt*(10)t-1t is a natural number, determined by the specific value of X, the sign of X: bSign, using true/false to represent "+" or "-”
Then, X is in accordance with 2nAnd (n is a natural number) carrying out coding. The encoding process is implemented by two cycles, a large cycle is embedded with a small cycle, the large cycle traverses all the encoded characters, and the small cycle traverses a single character pair 2 of the large cyclenAnd carrying out rounding operation and complementation operation.
The major cycle means that X is first followedtGo through to X1All characters in the character string are looped and binary coded to obtain a coded character string and a first level base.
The code string and the first level base number are obtained by a small loop, namely, a unit number (X) extracted from a large looptTo X1) To 2nAnd performing rounding operation and complementation operation to obtain a quotient and a remainder part, taking the sum of the product of the remainder part and 10 and the next digit character as the part for starting operation of the next small cycle, and accumulating the obtained quotient to be used as a character string of the new large cycle. This process is repeated until the string becomes an empty string, and the loop ends. The number of the large-loop cycles is the number of the super-long digits, and the residue result obtained by the last operation of the small loop embedded in the large loop for one time is the base number of the corresponding number of the large loop.
Definition of α ═ α12,……,αk]For each small cycle, β ═ β12,……,βγ]U is the remainder of each small cycle, i.e. the number of layers after encoding the super-long digits of the hierarchy, γ is the number of small cycles in one large cycle, βγAnd representing the number obtained by the last small circulation, namely the base number of the corresponding layer, wherein u, e, k and gamma all belong to natural numbers. The specific process is as follows:
the first large loop traversal character string X ═ XtXt-1…X1Binary encoding each character in the string to obtain an encoded string and a first level base:
first minor cycle: xt→Xt/2n=α1,Xt%2n=β1,X→α1Xt-1…X1
And (3) a second small circulation:
Xt-11*10→(Xt-11*10)/2n=α2,(Xt-11*10)%2n=β2,X→α1α2Xt-2…X1
……
the γ th minor cycle:
X1γ-1*10→(X1γ-1*10)/2n=αγ,(X1γ-1*10)%2n=βγ,X→α1α2…αγ
completing the first major cycle to obtain a new code character string: alpha is alpha1α2…αγAnd a first level radix X1'=βγ
The new encoding string is then: alpha is alpha1α2…αγAs a string of traversal of the next major loop. Second major loop from string alpha1α2…αγThe non-0 character starts to traverse to obtain a newly generated code string and a next level base, and the specific process is consistent with a small loop process to obtain the newly generated string and the next level base:
……
starting the u-th major cycle, and the minor cycle process is the same as the above until the finally generated character string is empty, thereby obtaining the highest layer u and the highest layer base Xu'=βγ. u is the number of layers of the coded X', and the number of coded super-long bits is as follows: x '═ X'1,X'2,……,X'u]Wherein the symbol of the code X 'is X'. bSign, the number of layers is CX=u;X'uThe code represented is 0 to 2n-1, resulting in a very long bit number code X'. Thus, the hierarchical super-long bit number code is generated based on the number of layers and the cardinality of each level, and the following expansion is carried out:
X'=X′1*(2n)0+X'2*(2n)1+……+X'u*(2n)u-1u belongs to a natural number, symbol of X': x'. bSign.
In step S2, a subtraction operation is performed based on the sign of the super-long digit participating in the super-long digit subtraction and the super-long digit code generated based on the super-long digit. Fig. 2 is a flow chart of a preferred embodiment of the subtraction calculation process of the processing method of the super-long bit number subtraction of the present invention.
As shown in fig. 2, first, in step S21, the hierarchical super long digit codes M 'and N' are generated based on the two super long digits M and N participating in the super long digit subtraction, that is, the two super long digits M and N are expressed as follows in decimal terms by a polynomial:
M=M1*(10)0+M2*(10)1+……+Mi*(10)i-1i belongs to a natural number, the sign of M: bSign;
N=N1*(10)0+N2*(10)1+……+Mj*(10)j-1j belongs to a natural number, the sign of N: bsign.
Then, M and N are as 2nThe (n is a natural number) system is encoded, and the encoding process is performed according to the example in step S1. Generating the hierarchical super long bit number codes M 'and N':
M'=M′1*(2n)0+M'2*(2n)1+……+M'u*(2n)u-1u is the number of layers of the super-long digit M, M'1,M'2,……,M'uIs the base number of each layer; the sign of M 'is M'. bSign,
N'=N′1*(2n)0+N'2*(2n)1+……+N'v*(2n)v-1v is the number of layers of the super-long digit number N, and the sign of N 'is N'. bSign. In the present invention, only two very long digits of the same sign are subtracted.
Determining the sign of the subtraction result (resAdd), when M + N:
when m.bsign and n.bsign are true or false, if M > N (corresponding numerical comparison), the resMinus result symbol is true, otherwise it is false;
when m.bsign and n.bsign have different signs, m.bsign is true, and n.bsign is false, the sign of result resMinus is true; bsign is false, and n bsign is true, then resMinus is signed false.
In the invention, only two super-long digits with the same sign are subtracted, and the subtracted number is larger than the subtracted number in the calculation. In this embodiment, the signs of the two super long bit numbers M and N are the same and the super long bit number code M 'of the hierarchical level is greater than the super long bit number code N' of the hierarchical level.
In a specific calculation process, first, the intermediate subtraction difference, the borrow number, and the number of subtraction results involved in the subtraction process may be defined and respectively represented by sub, R, and J, where subscripts u, v, and t belong to natural numbers, u represents the number of layers of M ', and v represents the number of layers of N'.
sub=[sub1,sub2,……,subt],subtThe corresponding intermediate subtraction difference of the t layers;
J=[J1,J2,……,Jt],Jtborrowing numbers corresponding to the t layers;
resMinus=[R1,R2,……,Rt],Rtis the final subtraction difference of the t layers.
In step S22, the hierarchical super-long bit number codes M 'and the hierarchical super-long bit number codes N' are arranged from right to left according to the hierarchy from low to high, an intermediate subtraction difference for each hierarchy is calculated, and each intermediate subtraction difference is binary-coded to obtain a borrow number and a subtraction result number for each hierarchy.
According to the codes, the SDN manager performs distributed parallel arrangement and distribution, and the data corresponding to two codes in the same coding level are distributed to the same computing node for computing. The case where u ≠ v is explained from the encoding, and if u ≠ v, the arithmetic can be performed by filling the high-level hierarchy of the small number with 0. Arranging the super-long bit number codes M 'and N' from right to left according to a low level, wherein the same coding level of the M 'and the N' is correspondingly arranged as follows:
Figure BDA0002562106270000101
in the calculation process, the SDN manager can dynamically distribute calculation tasks to each sub-node in parallel, and each sub-node respectively calculates (M'1-N′1),(M'2-N'2),……,(M′u-N′v) Then obtain (sub)1,J1),(sub2,J2),……,(subt,Jt) Then, the SDN controller calculates the result to obtain a final super-long digit subtraction result resMinus ═ R1,R2,……,Rt]。
The first level is calculated. Calculate sub first1=M′1-N′1The polynomial can be expressed as: sub1=M′1×(2n)0-N′1×(2n)0The calculation process is again according to 2nThe encoding is performed.
Then judge sub1Positive and negative:
if sub1Greater than or equal to 0, then R1=sub1Number of borrow J1=0;
If sub1<0, then R1=sub1+2nNumber of borrow J1=1;
The first level of operation is complete.
A second hierarchy level is then computed. sub2=M'2-N'2-J1The polynomial can be expressed as: sub2=M'2×(2n)1-N'2×(2n)1-J1×(2n)1The calculation process is again according to 2nThe encoding is performed.
Then judge sub2Positive and negative:
if sub2Greater than or equal to 0, then R2=sub2Number of borrow J2=0;
If sub2<0, then R2=sub2+2nNumber of borrow J2=1;
The second level of operation is complete.
Similarly, the computation is performed for the third level up to the t-1 th level.
At the t-1 level, sub is also calculated firstt-1=M'u-1-N′v-1-Jt-2The polynomial can be expressed as: subt-1=M′u-1×(2n)u-2-N′v-1×(2n)v-2-Jt-2×(2n)t-2The calculation process is again according to 2nThe encoding is performed.
Then judge subt-1Positive and negative:
if subt-1Greater than or equal to 0, then Rt-1=subt-1Number of borrow Jt-1=0;
If subt-1<0, then Rt-1=subt-1+2nNumber of borrow Jt-1=1。
The operation of the t-1 th level is completed.
Further, the t level is calculated, and sub is calculated firstlyt=M′t-N′t-Jt-1The polynomial can be expressed as: subt=M'u×(2n)u-1-N′v×(2n)v-1-Jt-1×(2n)t-1The calculation process is again according to 2nThe encoding is performed.
Rt=subt
And finishing the operation of the t level and describing the subtraction operation process.
Then, step S23 is executed to determine the sign of resMinus, and obtain the subtraction result resMinus ═ R1,R2,……,Rt](t is a natural number, 0. ltoreq. Rt<2n) The symbols are: bsign, res minus. The subtraction result can be expressed in polynomial form as:
resMinus=R1*(2n)0+R2*(2n)1+……+Rt*(2n)t-1t is a natural number; symbol of resMinus: bsign, res minus.
At this point, the subtraction of the very long digits is completed.
The following embodiment is used to describe a specific encoding process of two extra-long digits, and the two extra-long digits after encoding are subtracted, and the subtraction process is exemplified.
Example 1:
determining two super-long bit numbers A and B to be coded:
A=120623479892889324486908;B=27801936763830785484783867。
as mentioned above, the specific encoding process is as follows:
each bit character in the variable of the A and B character string type is paired with 216And performing rounding operation and remainder operation to obtain a quotient and a remainder, multiplying the remainder by 10 to obtain a cumulative part which is used as the initial operation part of the next character, obtaining the remainder as the base number of the corresponding layer number in the last small cycle, continuously repeating the process until the character string becomes an empty character string, and ending the cycle. And (4) once a large cycle (all characters in the character string cycle once), the remainder result is a base number corresponding to the super-long digit level.
Operating on string a-120623479892889324486908:
the first major loop, traverse the string: 120623479892889324486908:
first minor cycle: 1 → 1/216=0,reminder→1%216=1,
And 120623479892889324486908 → 020623479892889324486908;
and (3) a second small circulation: 2+1 10 → 12/216=0,reminder→12%216=12,
And 020623479892889324486908 → 000623479892889324486908;
and (3) a third small circulation: 0+12 10 → 120/216=0,reminder→12%216=120,
And 000623479892889324486908 → 000623479892889324486908;
...
the last small cycle, timer 252.
The second major cycle, the minor cycle is as above, and the timer is 1480.
The third large cycle, the small cycle is as above, and the timer is 65535.
The fourth major cycle, the minor cycle, is as above, and the timer is 782.
The fifth major loop, traversal starts with non-0 characters of the string:
first minor cycle: as above.
...
And (3) final small circulation: 6539 → 6539/216=0,reminder=6539%2166539, string → 0.
Obtaining an ultra-long bit number code: a' ═ 252,1480,65535,782,6539;
and (3) finishing all the cycles to obtain 5 levels of the ultra-long digit A, wherein the corresponding cardinality of each level is as follows: 252,1480,65535,782,6539.
After 5 times of the large loop character string 120623479892889324486908, the number of layers is 5, and m _ len is 5 in the corresponding super-long digit structure.
So far, the conversion of the ultra-long digit A is completed, and the converted code is as follows: a' ═ 252,1480,65535,782,6539], the notation is: a'. bSign ═ true.
The process is a reversible process, namely, the corresponding super-long digit can be obtained by the number of levels in the super-long digit structure and the cardinal number corresponding to the levels, and the process can be expressed by a polynomial as follows:
A'=252*(216)0+1480*(216)1+65535*(216)2+782*(216)3+6539(216)4
in summary, the cardinality analogy corresponding to the hierarchy is the number, tens, hundreds, thousands, etc. in the decimal system.
Similarly, the same operation is performed for the very long bit number B:
the first major loop, traverse string B27801936763830785484783867:
first minor cycle: 2 → 2/216=0,reminder→2%216=2,
And 27801936763830785484783867 → 07801936763830785484783867;
and (3) a second small circulation: 7+2 10 → 27/216=0,reminder→27%216=27,
And 07801936763830785484783867 → 00801936763830785484783867;
and (3) a third small circulation: 8+27 10 → 278/216=0,reminder→278%216=278,
And 00801936763830785484783867 → 00001936763830785484783867;
...
the last small cycle, timer 251.
The second large cycle, the small cycle is as above, and the timer is 148.
The third large cycle, the small cycle is as above, and the timer is 535.
The fourth major cycle, the minor cycle, is as above, and the timer is 782.
The fifth major cycle and the minor cycle are as above, and the timer is 65354.
The sixth major loop, traversal starts with the non-0 character of the string:
first minor cycle: as above.
...
And (3) final small circulation: 22 → 22/216=0,reminder=22%21622, string → 0.
B'=[251,148,535,782,65354,22];
And (3) finishing all the circulation to obtain 6 levels of the super-long digit B, wherein the corresponding cardinality of each level is as follows: 251,148,535,782,65354, 22.
After 6 times of the large loop character string 27801936763830785484783867, the number of layers is 6, and m _ len in the corresponding super-long digit structure is 6.
So far, the conversion of the super-long bit number B is completed, and the converted code is: b' ═ 251,148,535,782,65354, 22, the notation is: b'. bSign ═ true.
The process is a reversible process, namely, the corresponding super-long digit can be obtained by the number of levels in the super-long digit structure and the cardinal number corresponding to the levels, and the process can be expressed by a polynomial as follows:
B'=251*(216)0+148*(216)1+535*(216)2+782*(216)3+65354*(216)4+22*(216)5
in summary, the cardinality analogy corresponding to the hierarchy is the number, tens, hundreds, thousands, etc. in the decimal system.
So far, the encoding process of two super-long digits of the embodiment is finished.
Since their signs are all "+", a.bsign ═ true, b.bsign ═ true, and readd.bsign ═ true. Hierarchical super-long bit number coding is obtained as before:
A'=[252,1480,65535,782,6539];
B'=[251,148,535,782,65354,22];
a 'and B' can be represented by polynomials as follows:
A'=252×(216)0+1480×(216)1+65535×(216)2+782×(216)3+6539×(216)4
B'=251×(216)0+148×(216)1+535×(216)2+782×(216)3+65354×(216)4+22×(216)5
the specific process of the subtraction of A 'and B' is as follows:
determining the subtrahend as: and B is 27801936763830785484783867.
The number of subtractions is: and A is 120623479892889324486908.
And their signs are all "+", so a.bsign ═ true, b.bsign ═ true, and readd.bsign ═ true.
Hierarchical super-long bit number coding is obtained as before:
A'=[252,1480,65535,782,6539];
B'=[251,148,535,782,65354,22];
A'=252×(216)0+1480×(216)1+65535×(216)2+782×(216)3+6539×(216)4
B'=251×(216)0+148×(216)1+535×(216)2+782×(216)3+65354×(216)4+22×(216)5
the calculation process is as follows:
Figure BDA0002562106270000151
Figure BDA0002562106270000161
calculating the highest bit:
Figure BDA0002562106270000162
resMinus corresponds to hierarchy cardinality:
resMinus.m_data[]=[65535,63845,563,65535,58814,22]
resMinus.m_len=max(A.m_len,B.m_len)=6
res Minus. m _ data [5] (22)! Is equal to 0, therefore
resMinus.bSign=true
resMinus.m_len=6
Obtaining a subtraction result:
resMinus.m_data[]=[65535,63845,563,65535,58814,22]
so far, the example of the encoding process and the subtraction calculation process of the ultra-long bit number is completed, and the embodiment 1 is ended.
The processing method of the super-long digit subtraction can be applied to calculation scenes of factorization of super-long digits, super-high-dimensionality matrix calculation, image processing and the like. For example, solving the problem of solving the factorization process of the ultra-long bit number by using the shor algorithmThe encoding of the super-long digit and the calculation process of the super-long digit are required. The factorization process for solving the ultra-long digit by using the shor algorithm is to use more than 264After the super-long bit number is encoded, the total number of layers calculated by the SDN controller according to the processing method of the super-long bit number subtraction is distributed to different corresponding number of distributed computing nodes according to task requirements, and the data in each node exceeds 264-1, performing a representation calculation according to a coded hierarchical scale of very long bits. In the process of decomposing the ultra-long bit large combination number N by using the shor algorithm, the SDN controller comprehensively collects and controls the result to obtain a final ultra-long bit calculation result. Therefore, when the shor algorithm is used for solving the prime factor of the overlength bit large composite number N, the required data operation exceeds the maximum data representation of the existing computer (2)64-1) in which the encoding of the very long number of bits and the subtraction of the very long number of bits are used. Therefore, the problem that the existing computer cannot be used for calculation due to too large data can be well solved by using the super-long bit number coding and the super-long bit number subtraction operation for calculation.
FIG. 3 is a flow chart of a specific embodiment of factoring according to the Shor algorithm using the ultra-long bit number coding processing method of the present invention. As shown in fig. 3, one will exceed 2512The large resultant A is calculated by a Shor algorithm according to an ultra-long digit coding operation process, wherein the calculation process comprises a subtraction calculation process of the ultra-long digits.
As shown in step S31 in fig. 3, the ultra-long bit composite is determined:
A=89884656743115795386465259539451236680898848947115328636715040578866337902750481566354238661203768010560056939935696678829394884407208311246423715323561981300002286071312272406526781657562786883878946793069280737057523435732477591317599646617126077367662938702372050520303688765359321867171510601857712632753。
the total number is calculated by adopting a traditional calculation method, the difficulty of exceeding the computer representation bit exists in the existing computer, and the difficulty can be well solved based on the method of the invention.
And then according to the step S32, carrying out super-long digit coding on the super-long digit composite number A to obtain hierarchical super-long digit coding.
And finally, according to the substep S33, the coded overlength digit A is coded according to the overlength digit by using a Shor algorithm, wherein the processing method comprises the overlength digit subtraction processing method of the invention, and quality factors q1 and q2 are solved. The result obtained after calculation is:
q1=6703903964971298549787012499102923063739682910296196688861780721860882015036773488400937149083451713845015929093243025426876941405973284973216824503307637。
q2=13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006123469。
the invention provides a coding method of super-long digit which exceeds the current computer processing digit, and is convenient for computing the super-long digit under the existing computing system. The present invention is based on the existing computer architecture and combines an ultra-long digit number N (generally more than 2)64-1), performing symbol extraction and then coding by symbol computation into a hierarchical coding that can directly participate in the operation, the coded data structure comprising: coding symbols, the number of coding levels and a grading base number corresponding to each level, and the three steps realize the coding of the ultra-long digit. The invention further provides a subtraction calculation method based on the super-long digit code, and the exponential-level quick calculation speed is realized. The invention also discloses a subtraction calculation method and a calculation process of the super-long digit code based on the defined super-long digit code, and realizes the exponential-level quick calculation of the long super-digit code. The method provided can meet the requirement of rapid information processing of big data calculation.
Another technical solution adopted by the present invention to solve the technical problem is to construct a computer-readable storage medium, on which a computer program is stored, wherein the computer program, when executed by a processor, implements the method for preventing timestamp attacks in a blockchain system.
Accordingly, the present invention can be realized in hardware, software, or a combination of hardware and software. The present invention can be realized in a centralized fashion in at least one computer system, or in a distributed fashion where different elements are spread across several interconnected computer systems. Any kind of computer system or other apparatus adapted for carrying out the methods of the present invention is suited. A typical combination of hardware and software could be a general purpose computer system with a computer program that, when being loaded and executed, controls the computer system such that it carries out the methods described herein.
The present invention may also be implemented by a computer program product, comprising all the features enabling the implementation of the methods of the invention, when loaded in a computer system. The computer program in this document refers to: any expression, in any programming language, code or notation, of a set of instructions intended to cause a system having an information processing capability to perform a particular function either directly or after either or both of the following: a) conversion to other languages, codes or symbols; b) reproduced in a different format.
While the invention has been described with reference to specific embodiments, it will be understood by those skilled in the art that various changes may be made and equivalents may be substituted without departing from the scope of the invention. In addition, many modifications may be made to adapt a particular situation or material to the teachings of the invention without departing from its scope. Therefore, it is intended that the invention not be limited to the particular embodiment disclosed, but that the invention will include all embodiments falling within the scope of the appended claims.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents and improvements made within the spirit and principle of the present invention are intended to be included within the scope of the present invention.

Claims (10)

1. A processing method for super-long bit number subtraction is characterized by comprising the following steps:
s1, coding the super-long digit number based on the coding mode and the base number of the calculation system to generate a hierarchical super-long digit number code;
and S2, carrying out subtraction operation according to the sign of the super-long digit participating in the super-long digit subtraction and the super-long digit code generated according to the super-long digit.
2. The processing method of super-long bit number subtraction as claimed in claim 1, wherein the step S1 further comprises:
s11, adopting polynomial to change X into X for decimal super-long digit numbertXt-1……X1Expressed as X ═ X1*(10)0+X2*(10)1+……+Xt*(10)t-1T is a natural number, and the sign of X is X.bSign;
s12 traversing character string XtXt-1…X1Binary coding each character in the character string to obtain a coded character string and a first level base;
s13, traversing the code character string from the first non-zero character of the code character string, and carrying out binary coding on each character in the code character string to obtain a newly generated code character string and a next level base number; and carrying out binary coding on the newly generated coded character string obtained by each traversal until the finally generated character string is empty, and generating the hierarchical ultra-long bit number code based on the number of layers and the cardinal number of each level.
3. The processing method for super long bit number subtraction according to claim 2, wherein the step S12 further includes:
s121, traversing the character string X as X based on the following formulatXt-1…X1Binary encoding each character in the string to obtain an encoded string and a first level base:
based on Xt→Xt/2n=α1,Xt%2n=β1,X→α1Xt-1…X1
Xt-11*10→(Xt-11*10)/2n=α2,(Xt-11*10)%2n=β2,X→α1α2Xt-2…X1
……
X1γ-1*10→(X1γ-1*10)/2n=αγ,(X1γ-1*10)%2n=βγ,X→α1α2…αγ
Wherein the code string is alpha1α2…αγThe first level base is ═ βγ(ii) a n represents the maximum number of digits that the computer can calculate,% represents remainder, and/represents quotient, which are all integer operations.
4. The processing method for super long bit number subtraction according to claim 3, wherein the step S13 further includes:
s131, from the code character string alpha1α2…αγStarts with the first non-zero character of alpha1α2…αγAs X, the step S121 is performed to obtain a newly generated character string and a next level base;
s132, repeating the step S131 on the newly generated character string until the finally generated character string is empty;
s133, generating the hierarchical super-long bit number coding X ' ═ X ' based on the number of layers and the cardinality per hierarchy '1*(2n)0+X'2*(2n)1+……+X'u*(2n)u-1Wherein u represents the number of layers, X'1,X'2,……,X'uIs the base of each layer.
5. The processing method of super-long bit number subtraction according to claim 4, wherein the step S2 further includes:
s21, generating the hierarchical super long bit number coding M 'and N' based on the two super long bit numbers M and N participating in super long bit number subtraction, wherein the two super long bit numbers M and N have the same sign and the hierarchical super long bit number coding M 'is greater than the hierarchical super long bit number coding N':
M'=M'1*(2n)0+M'2*(2n)1+……+M'u*(2n)u-1u is the number of layers of the super-long digit M, M'1,M'2,……,M'uIs the base number of each layer,
N'=N'1*(2n)0+N'2*(2n)1+……+N'v*(2n)v-1v is the number of layers of the super-long digit N;
s22, taking the super-long digit codes M ' of the hierarchical levels as minuets, taking the super-long digit codes N ' of the hierarchical levels as minuets, arranging the super-long digit codes N ' of the hierarchical levels from right to left according to the hierarchical levels from low to high, calculating the intermediate subtraction difference of each hierarchical level, and carrying out binary coding on each intermediate subtraction difference to obtain borrows and subtraction result numbers of each hierarchical level;
and S23, determining a final subtraction result based on the subtraction result number of each level and the borrow number of each level, and determining the sign of the subtraction result number based on the signs of the super-long digit number codes M 'and N' of the hierarchical levels.
6. The processing method for super long bit number subtraction according to claim 5, wherein the step S22 further includes:
s221, arranging the hierarchical super-long digit number codes M 'and the hierarchical super-long digit number codes N' from right to left according to the hierarchy from low to high to calculate the subtraction result resMinus ═ R1,R2,……,Rt]:
Figure FDA0002562106260000031
S222, for each level, calculating the intermediate subtraction difference of the level according to binary expansion based on the number of codes in the level, and calculating the intermediate subtraction difference based on the intermediate subtractionDifference and 2nThe borrow number and the subtraction result number of the hierarchy are calculated according to the comparison result of the step number and the subtraction result number.
7. The method for processing the super-long bit number subtraction according to claim 6, wherein the step S222 further comprises:
s2221, borrow number J for the first level0Calculating an intermediate subtraction difference sub for the first level 01=M'1-N'1-J0And judging the intermediate subtraction difference sub1When the intermediate subtraction difference sub1Positive, the number of subtraction results R of the first level1=sub1Borrow number J of the first level10; when the intermediate subtraction difference sub1Negative, the number of subtraction results R of the first level1=sub1+2nBorrow number J of the first level1=1;
S2222, for the second level to the t-1 level, repeatedly executing the step S2221 to calculate the subtraction result number and borrow number of each level;
s2223, for the t level, calculating the intermediate subtraction difference sub of the t levelt=M't-N't-Jt-1Setting the number of subtraction results R of the t-th levelt=subt
8. The method of claim 7, wherein in step S23, the subtraction result resMinus ═ R is used1*(2n)0+R2*(2n)1+……+Rt*(2n)t-1T is a natural number; symbol of resMinus: bsign, res minus.
9. The processing method of ultralong bit number subtraction according to claim 8, wherein in step S2, the SDN controller distributes the calculation task in parallel to each child node, and each child node calculates (M'1-N'1),(M'2-N'2),……,(M'u-N'v) Then the result of the calculation (sub)1,J1),(sub2,J2),……,(subt,Jt) Returning to the SDN controller, the SND controller collects the subtraction result resMinus ═ R1,R2,……,Rt]。
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the processing method of the very long bit subtraction according to any of claims 1 to 9.
CN202010618103.XA 2020-06-30 2020-06-30 Processing method for super-long digit subtraction and computer readable storage medium Pending CN111831253A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010618103.XA CN111831253A (en) 2020-06-30 2020-06-30 Processing method for super-long digit subtraction and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010618103.XA CN111831253A (en) 2020-06-30 2020-06-30 Processing method for super-long digit subtraction and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN111831253A true CN111831253A (en) 2020-10-27

Family

ID=72899979

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010618103.XA Pending CN111831253A (en) 2020-06-30 2020-06-30 Processing method for super-long digit subtraction and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN111831253A (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101105832A (en) * 2007-08-13 2008-01-16 浙江工业大学 Relational database water mark embed and extraction method based on (t,n) threshold
WO2012090288A1 (en) * 2010-12-27 2012-07-05 富士通株式会社 Cryptographic processing device, method of cryptographic processing and program
CN106294371A (en) * 2015-05-15 2017-01-04 阿里巴巴集团控股有限公司 Character string codomain cutting method and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101105832A (en) * 2007-08-13 2008-01-16 浙江工业大学 Relational database water mark embed and extraction method based on (t,n) threshold
WO2012090288A1 (en) * 2010-12-27 2012-07-05 富士通株式会社 Cryptographic processing device, method of cryptographic processing and program
CN106294371A (en) * 2015-05-15 2017-01-04 阿里巴巴集团控股有限公司 Character string codomain cutting method and device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
DAMONMAI: "一个超长字符串表示的十进制数转化为十六进制的字符串", 《HTTPS://BLOG.51CTO.COM/U_9492221/1564392》 *
余发高 等: "大数运算实现的相关技术研究", 《武汉纺织大学学报》 *

Similar Documents

Publication Publication Date Title
Cortese et al. Loading classical data into a quantum computer
Wolfram Random sequence generation by cellular automata
Hasan et al. A modified Massey-Omura parallel multiplier for a class of finite fields
Laporta High-precision ϵ-expansions of massive four-loop vacuum bubbles
von zur Gathen Irreducibility of multivariate polynomials
CN112162723A (en) Quantum addition operation method and device, electronic device and storage medium
KR100756137B1 (en) Division and square root arithmetic unit
Iliev et al. A Note on Knuth’s Implementation of Extended Euclidean Greatest Common Divisor Algorithm
JP2009003925A (en) Extension of repetition period of random sequence
Sharma Complexity of real root isolation using continued fractions
CN111062610B (en) Power system state estimation method and system based on information matrix sparse solution
Iliev et al. A New Improvement of Least Absolute Remainder Algorithm for Greatest Common Divisor. III
Iliev et al. A New Improvement Euclidean Algorithm for Greatest Common Divisor. I
CN111831253A (en) Processing method for super-long digit subtraction and computer readable storage medium
CN111831252A (en) Processing method for super-long digit addition and computer readable storage medium
CN112364985A (en) Convolution optimization method based on distributed coding
CN111831255A (en) Processing method and computer readable storage medium for ultra-long digit multiplication
CN111831256A (en) Processing method of ultra-long digit division and computer readable storage medium
JP3953253B2 (en) Cipher generation device, electronic device using cipher generation program, storage medium, ciphertext decryption device
Zhan Quantum Multiplier Based on Exponent Adder
Schoenbaum A Tapered Floating Point Extension for the Redundant Signed Radix 2 System Using the Canonical Recoding
Jin et al. A Polarity-based approach for optimization of multivalued quantum multiplexers with arbitrary single-qubit target gates
CN110046875B (en) Hardware implementation method and device of siacoin ore excavation algorithm
Surguladze Computer Programs for Analytical Perturbative Calculations in High Energy Physics
Carney et al. Universal Statistical Simulator

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20201027