JP2004178539A - Numerical calculation by using character type data in computer - Google Patents
Numerical calculation by using character type data in computer Download PDFInfo
- Publication number
- JP2004178539A JP2004178539A JP2002382779A JP2002382779A JP2004178539A JP 2004178539 A JP2004178539 A JP 2004178539A JP 2002382779 A JP2002382779 A JP 2002382779A JP 2002382779 A JP2002382779 A JP 2002382779A JP 2004178539 A JP2004178539 A JP 2004178539A
- Authority
- JP
- Japan
- Prior art keywords
- calculation
- computer
- numerical
- character string
- data
- 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
Landscapes
- Executing Machine-Instructions (AREA)
Abstract
Description
【0001】
【発明の属する技術分野】
本発明は、コンピュータの数値計算において、扱う数値の桁数における制限を廃し、桁落ちを防ぐものである。
【0002】
【従来の技術】
従来のコンピュータにおける数値計算は、中央演算処理装置もしくは数値演算プロセッサ等におけるハードウェアが担当し、ソフトウェアはハードウェアに計算項目を渡し、その演算結果を受け取ることで実現している。
【0003】
ほとんどのコンピュータでは数値の扱いをIEEE(Institute of Electrical and Electronic Engineers)等の国際規格に準拠している。
【0004】
【発明が解決しようとする課題】
ハードウェアによる演算は高速かつ、正確な内容が期待できるが、その数値演算のためのハードウェアの設計段階で数値の桁数に制限が設けられるため、桁数の大きな演算を行う場合に桁落ちが生じる。
【0005】
コンピュータ内で、計算の対象となる数値データ、もしくは計算途中に算出された数値データに一度桁落ちが生じると、その計算結果における数値の信頼性は大きく損なわれる。
【0006】
本発明は大きな桁を扱う数値データで、四則演算のうち加算、減算、乗算においては桁落ちの発生しない手法を示す事、除算においては任意の算出桁数を指定することにより、納得のいく計算結果を示す事を最終的な目的としている。
【0007】
【課題を解決するための手段】
上記目的を達成するために本発明で行う数値計算は、コンピュータ内部で数値データを文字列で保持し、計算の対象とする。
【0008】
計算結果を格納する文字列の大きさは、計算項目の桁数と演算子を参照する事で予想が可能である。
【0009】
計算を行おうとするコンピュータのオペレーティングシステムの設計思想が、UNIX(登録商標)に準じたもの、もしくはUNIX(登録商標)の機能を完全に用意しているものである場合は、プログラムは実行中にコンピュータの記憶装置(Random Access Memory、以下メモリ)の空きエリアに任意の大きさの配列を要求できる。
【0010】
最近のオペレーティングシステムは、ほとんどがプログラムからの要求に対してメモリの臨時割り当て(メモリーアロケーション)が可能であり、割り当ての大きさの制限がコンピュータとオペレーティングシステムの固有の性能に依存する状態として存在するものの、本発明の目的を満たす仕様を保持している。
【0011】
計算結果の格納する文字列は、臨時に割り当てられた文字列データ(単体では1バイト)へ格納、最終的には臨時ではないエリアに移せばよい。
【0012】
2つの文字列データに対しての加減乗除計算のアルゴリズムは、小学校課程で習得する方法で十分対応できる。
【0013】
人がコンピュータに要求する計算内容の記述は、従来の技術で対応可能である。
【0014】
例えば、「97+34」という文字列の記述をコンピュータに与えれば、「97」と「34」は数値として解釈が可能であり、間にある「+」演算子は左右に並ぶ2つの数値を加算するための記号と解釈可能であり、また式そのものの意味を理解するアルゴリズムは既に存在する。
【0015】
【発明の実施の形態】
本発明は、本明細書「請求項1」で「文字列をそのまま数値として扱う手段」としているが、実際にはこの理論をプログラム化して、実際にコンピュータ上で稼動可能とするアプリケーションプログラムを作成することが大きな課題となる。
【0016】
基本的に作成する必要のあるアプリケーションプログラムは、人からコンピュータに与える式のデータを解釈するプログラムと、解釈された式の内容を加減乗除に振り分け演算を行うための4つのプログラム、計5つとなり、計算の機能をさらに拡張すればそれ以上の数となる。
【0017】
式のデータの解釈とは、「12×(34+56)」の文字列を、34と56を先に加算して、その演算結果と12を乗算する等、計算の優先順位や手順を式から読み取ることで、この技術は上記にもあるとおり、既存している。
【0018】
加減乗除の4プログラムのうち、加減乗算の3プログラムは、2つの計算対象となる数値データを文字列(ポインタ)として設置し、演算結果を受け取る文字列データエリア(ポインタ)を用意、設置し、除算のプログラムについては、さらに小数点以下の必要とする桁数を指定する項目を設置することが必要となる。
【0019】
大きすぎる演算結果には、丸め等の桁処理を行う必要があるが、桁処理のためのプログラムを用意するかどうかはプログラム作成者の判断、もしくは演算の実行者の判断による。
【0020】
【実施例】
本発明の加算の例として、「97+34」の計算を以下に記述する。
【0021】
このとき、式中の数値「97」は、2バイトの文字列であり、終端記号が存在すれば、3バイトの文字列である。
【0022】
文字列データであるゆえに、このときの数値「97」は、コンピュータは内部データとして「3937」(16進数)と記憶している。
【0023】
さらに、式中の数値「34」も2バイトもしくは3バイトであり、記号「+」は1バイトもしくは2バイトの文字列であり、コンピュータの内部データではそれぞれ「3334」(16進数)「2B」(16進数)と記憶している。
【0024】
【0025】
上記▲1▼と▲2▼は文字列データで、演算の対象であり、加算することが目的である。
【0026】
▲3▼は桁上がりのために用意されたメモリの臨時割り当て文字列データエリアで、演算子が「+」と既知であるため必要とする大きさは予想できる。
【0027】
▲4▼は計算結果が格納される文字列データエリアで、計算結果の桁数は予想できるため、メモリの臨時割り当ては可能である。
【0028】
▲4▼の計算結果は、▲1▼▲2▼のそれぞれの桁を加算し、▲3▼のエリアに桁上がりを記述し、実際には▲1▼▲2▼▲3▼のそれぞれの桁を加算した結果の一桁目を表示している。
【0029】
このときの計算手段は、それぞれ縦1桁の数値だけを対象として行うため、文字型から整数型へ変換して計算し、必要な結果内容を文字型に変換して▲4▼のエリアに置いていく方法も考えられる。
【0030】
▲4▼の計算結果は、IEEE規格等への変換は可能であるが、計算結果の桁が大きすぎる場合は、変換の際に桁落ちが発生する可能性がある。
【0031】
【発明の効果】
本発明は、桁落ちによる計算の誤差の問題を解決する。
【0032】
例えば、直径1億光年の銀河の面積は何平方センチメートルか?等の要求に応えることができるため、宇宙開発にも応用でき、宇宙からの地球の地形図作成にも効果が期待できる。
【0033】
また、本発明は、前述したIEEE規格等の国際規格に準じないわけではなく、既存の技術も利用可能である。
【0034】
例えば、既存の方法で三角関数の実数値をIEEE規格等で得て、その数値を文字列に変換し、本発明内の計算手順内に組み込めば、少なくともIEEE規格での技術で算出される数値データよりは信頼性の高い計算結果データを得ることが可能となる。
【0035】
RS232C等を介して周辺装置に数値データを転送するときには、IEEE規格等の数値データから文字列データに変換して転送されるケースも見られるため、周辺機器が受け取る数値とすることはそう困難ではないことが予想できる。[0001]
TECHNICAL FIELD OF THE INVENTION
The present invention eliminates the restriction on the number of digits of a numerical value to be handled in a numerical calculation of a computer, and prevents digit loss.
[0002]
[Prior art]
In a conventional computer, numerical calculations are performed by hardware in a central processing unit or a numerical processor, and software is realized by passing calculation items to the hardware and receiving the calculation results.
[0003]
In most computers, the handling of numerical values conforms to international standards such as IEEE (Institute of Electrical and Electronic Engineers).
[0004]
[Problems to be solved by the invention]
High-speed and accurate calculations can be expected in hardware calculations, but the number of digits in numerical values is limited at the design stage of the hardware for numerical calculations. Occurs.
[0005]
In a computer, once a digit is lost in numerical data to be calculated or numerical data calculated in the middle of calculation, the reliability of the numerical value in the calculation result is greatly impaired.
[0006]
The present invention is a numerical data that handles large digits. In addition, subtraction and multiplication among the four arithmetic operations indicate a method that does not cause loss of digits, and in division, specify an arbitrary number of calculated digits to achieve a satisfactory calculation. The ultimate goal is to show the results.
[0007]
[Means for Solving the Problems]
In the numerical calculation performed by the present invention to achieve the above object, numerical data is stored in a computer as a character string and is to be calculated.
[0008]
The size of the character string that stores the calculation result can be predicted by referring to the number of digits of the calculation item and the operator.
[0009]
If the design philosophy of the operating system of the computer on which the calculation is to be performed conforms to UNIX (registered trademark) or completely provides the function of UNIX (registered trademark), the program is executed during execution. An array of an arbitrary size can be requested in a free area of a storage device (random access memory, hereinafter referred to as a memory) of a computer.
[0010]
Most modern operating systems allow temporary allocation of memory (memory allocation) in response to a request from a program, and the size of the allocation exists as a state depending on the inherent performance of the computer and the operating system. However, it retains specifications that meet the objectives of the present invention.
[0011]
The character string to be stored in the calculation result may be stored in temporarily allocated character string data (1 byte in a single unit), and may be finally moved to a non-temporary area.
[0012]
The algorithm for calculating addition, subtraction, multiplication, and division for two character string data can be sufficiently dealt with by a method learned in an elementary school course.
[0013]
Description of the calculation contents requested by a computer from a computer can be handled by conventional techniques.
[0014]
For example, if a description of a character string "97 + 34" is given to a computer, "97" and "34" can be interpreted as numerical values, and a "+" operator between them adds two numerical values arranged on the left and right. There are already algorithms that can be interpreted as symbols and understand the meaning of the expression itself.
[0015]
BEST MODE FOR CARRYING OUT THE INVENTION
According to the present invention, "claim 1" in this specification is "means for treating a character string as a numerical value as it is." In practice, this theory is programmed to create an application program that can be actually operated on a computer. Is a major issue.
[0016]
Basically, there are five application programs that need to be created: a program that interprets the data of an expression given from a person to a computer, and four programs that perform the calculation by dividing the interpreted expression into addition, subtraction, multiplication, and division. However, if the function of calculation is further expanded, the number will increase.
[0017]
Interpretation of the expression data means reading the calculation priority or procedure from the expression, such as adding the character string of “12 × (34 + 56)” to 34 and 56 first and multiplying the operation result by 12. As such, this technology already exists, as noted above.
[0018]
Of the four programs of addition, subtraction, multiplication, and division, three programs of addition, subtraction, and multiplication set two numerical data to be calculated as character strings (pointers), prepare and install character string data areas (pointers) for receiving operation results, For the division program, it is necessary to set an item for specifying the required number of digits after the decimal point.
[0019]
It is necessary to perform digit processing such as rounding for an operation result that is too large. Whether a program for digit processing is prepared depends on the judgment of the program creator or the operator of the operation.
[0020]
【Example】
As an example of the addition of the present invention, the calculation of “97 + 34” is described below.
[0021]
At this time, the numerical value “97” in the expression is a 2-byte character string, and if a terminal symbol exists, it is a 3-byte character string.
[0022]
Since the data is character string data, the computer stores “3937” (hexadecimal) as the internal data for the numerical value “97” at this time.
[0023]
Further, the numerical value “34” in the formula is also 2 bytes or 3 bytes, the symbol “+” is a 1-byte or 2-byte character string, and “3334” (hexadecimal) “2B” respectively in the internal data of the computer. (Hexadecimal number).
[0024]
[0025]
The above (1) and (2) are character string data, which are to be calculated, and whose purpose is to add.
[0026]
{Circle around (3)} is a temporary allocated character string data area of a memory prepared for carry, and the required size can be expected since the operator is known as “+”.
[0027]
{Circle around (4)} is a character string data area in which the calculation result is stored. Since the number of digits of the calculation result can be predicted, temporary allocation of the memory is possible.
[0028]
For the calculation result of (4), add each digit of (1) and (2) and describe the carry in the area of (3). Actually, each digit of (1) (2) (3) The first digit of the result of adding is displayed.
[0029]
At this time, since the calculation means is performed only for the numerical value of one vertical digit, the calculation is performed by converting the character type to the integer type, and the necessary result content is converted to the character type and placed in the area of (4). There is also a way to go.
[0030]
The calculation result of (4) can be converted to the IEEE standard or the like, but if the calculation result has too large a digit, digit conversion may occur during conversion.
[0031]
【The invention's effect】
The present invention solves the problem of calculation errors due to cancellation.
[0032]
For example, how many square centimeters is a galaxy 100 million light-years in diameter? Since it can meet the demands such as the above, it can be applied to space development, and it can be expected to be effective in creating topographic maps of the earth from space.
[0033]
Further, the present invention is not limited to the above-mentioned international standards such as the IEEE standard, and can use existing technologies.
[0034]
For example, if a real value of a trigonometric function is obtained according to the IEEE standard or the like by an existing method, and the value is converted into a character string and incorporated into a calculation procedure in the present invention, at least a numerical value calculated by the technology according to the IEEE standard It is possible to obtain calculation result data that is more reliable than data.
[0035]
When numeric data is transferred to a peripheral device via RS232C or the like, there are cases where numeric data of the IEEE standard or the like is converted into character string data and transferred. Not expected.
Claims (1)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2002382779A JP2004178539A (en) | 2002-11-28 | 2002-11-28 | Numerical calculation by using character type data in computer |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2002382779A JP2004178539A (en) | 2002-11-28 | 2002-11-28 | Numerical calculation by using character type data in computer |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2004178539A true JP2004178539A (en) | 2004-06-24 |
Family
ID=32708720
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2002382779A Pending JP2004178539A (en) | 2002-11-28 | 2002-11-28 | Numerical calculation by using character type data in computer |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2004178539A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2018116483A1 (en) * | 2016-12-21 | 2018-06-28 | 和己 阿部 | Calculation using numerical values represented inside a computer in undecimal or higher positional notation |
-
2002
- 2002-11-28 JP JP2002382779A patent/JP2004178539A/en active Pending
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2018116483A1 (en) * | 2016-12-21 | 2018-06-28 | 和己 阿部 | Calculation using numerical values represented inside a computer in undecimal or higher positional notation |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
KR101759266B1 (en) | Mapping processing logic having data parallel threads across processors | |
RU2598814C2 (en) | Vector type command for search level of inadequate element | |
US6151618A (en) | Safe general purpose virtual machine computing system | |
TWI252431B (en) | Binary translator | |
US8464033B2 (en) | Setting a flag bit to defer event handling to one of multiple safe points in an instruction stream | |
KR19990081958A (en) | Method and apparatus for array boundary inspection, and computer system comprising the same | |
JP2001508907A (en) | Processing unit for executing virtual machine instructions | |
KR19990081959A (en) | A processor and a computer system for executing a set of instructions received from a network or local memory | |
JPH09231093A (en) | Method and system for transfer of program control between two architectures | |
WO2018102767A1 (en) | Obfuscating source code sent, from a server computer, to a browser on a client computer | |
TW201732734A (en) | Apparatus and method for accelerating graph analytics | |
KR100735944B1 (en) | Method and computer program for single instruction multiple data management | |
JP4647164B2 (en) | Indefinite size variables in intermediate languages | |
US20090171651A1 (en) | Sdram-based tcam emulator for implementing multiway branch capabilities in an xml processor | |
US8631013B2 (en) | Non-intrusive data logging | |
Jann et al. | IBM POWER9 system software | |
JP2004178539A (en) | Numerical calculation by using character type data in computer | |
Blanchet et al. | Computer architecture | |
CN115328547A (en) | Data processing method, electronic equipment and storage medium | |
US7676651B2 (en) | Micro controller for decompressing and compressing variable length codes via a compressed code dictionary | |
CN101751356A (en) | Method, system and apparatus for improving direct memory access transfer efficiency | |
CN115904486A (en) | Code similarity detection method and device | |
US20020199176A1 (en) | Storing and retrieving of field descriptors in Java computing environments | |
JP2846904B2 (en) | Additional processing unit control method | |
JP4260895B2 (en) | Multiple format addressing in microcontrollers |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20050727 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20050809 |
|
A02 | Decision of refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A02 Effective date: 20060214 |
|
A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20060522 |