TW548533B - Method for fast calculating the square root of integers - Google Patents

Method for fast calculating the square root of integers Download PDF

Info

Publication number
TW548533B
TW548533B TW89127387A TW89127387A TW548533B TW 548533 B TW548533 B TW 548533B TW 89127387 A TW89127387 A TW 89127387A TW 89127387 A TW89127387 A TW 89127387A TW 548533 B TW548533 B TW 548533B
Authority
TW
Taiwan
Prior art keywords
square root
integer
square
fast
squared
Prior art date
Application number
TW89127387A
Other languages
Chinese (zh)
Inventor
Huai-Yan Chen
Wen-Hui Mao
Original Assignee
Inventec Besta 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 Inventec Besta Co Ltd filed Critical Inventec Besta Co Ltd
Priority to TW89127387A priority Critical patent/TW548533B/en
Application granted granted Critical
Publication of TW548533B publication Critical patent/TW548533B/en

Links

Landscapes

  • Instructional Devices (AREA)

Abstract

The present invention provides a method for fast calculating the square root of integers, which is to add 0.5 to a series of integers. After conducting squaring, the series formed by the integers after squaring has the characteristic of two-stage equal-distance series. With this characteristic, in an electronic product, there is established an index table formed by a series of integer progression of the squared numbers within the maximum range for the required square root in the program for conducting squaring operation. Thus, when the electronic product is conducting the squaring operation on the inputted squared number, it can look up the index table to ensure the trying starting number and the series increments, and use the exhausted cyclic operation method to calculate the integer most close to the square root through a small amount of adding operation.

Description

548533 A7 B7 經濟部智慧財產局員工消費合作社印製 五、發明說明(1 ) 發明背景: 近年來,由於高科技數位電子產業之迅速發展,各式小型化且易於移動之 掌上型電子產品’如:電子辭典及個人數位助理器(Personal Digital Assistant,簡 稱PDA)…等乃應運而生,其中由以個人數位助理器在今日眾多科技電子產品最 具市場潛力,該等電子產品之設計及發展,不僅朝著輕薄短小之市場趨勢,大步 邁進,其功能及用途之規劃,更爲滿足一般消費者之需求,而逐漸與一般電子消 費產品相結合,成爲一機多用途之電子通訊產品,如與一般行動電話相結合,即 成爲一具備行動電話功能之個人數位助理器,如難據機相結合,良卩成爲一具備 網際網路傳訊功能之個人數位助理器,諸如此類之構想,實不勝枚舉。目前,由 於該等電子裝置之中央處理單元之處理速度有限,且其資訊儲存空間亦受限於記 憶體容量之不足,致其無法對消費者提供更快速且豐富之信息,因此,如何在該 等電子裝置上’利用現有之硬體設備,對所儲存及接收之大量資料,進行更有效 之壓縮,以增加其儲存空間,彌補其記憶體容量之不足,並在使用該等資料時, 快速進行解壓縮,以有效提昇其作業效率,即成爲各該電子產品之設計及製造業 者所致力硏究之一重要課題。 現階段PDA產品之中央處理單元之處理速度比較慢,開平方運算都是由軟 體來實現,若產品中只需要整數級之數據,再採用浮點運算之函數庫來計算,不 僅不能滿足程序之要求,而且耗費主機之資源。例如:在一般安裝有電子地圖之 掌上型電子產品中,對於路名之標記,均係藉先求得該條道路之長度,再將該道 路之名字均勻分佈標示在該道路之條線段上。按照傳統方法,計算該條路之長度 係採用浮點函數庫之開平方函數,但道路比較多之時候,需要進行很多次精確之 開平方運算,而最後亦僅能求得最接近其平方根之整數,且測試結果顯示,其速 度較慢 > 並不能達到令使用者滿意之效果。 (請先閱讀背面之注意事項再548533 A7 B7 Printed by the Consumer Cooperatives of the Intellectual Property Bureau of the Ministry of Economic Affairs 5. Description of the invention (1) Background of the invention: In recent years, due to the rapid development of the high-tech digital electronics industry, various small-sized and easy-to-move handheld electronic products such as : Electronic dictionaries and Personal Digital Assistants (PDAs) ... emerged at the historic moment. Among them, personal digital assistants have the most market potential in many technological electronic products today. The design and development of these electronic products, Not only is it striding towards the trend of thin, light and short markets, its functions and uses are planned to better meet the needs of ordinary consumers, and gradually combine with general electronic consumer products to become a multi-purpose electronic communication product, such as Combined with general mobile phones, it becomes a personal digital assistant with mobile phone functions. If it is difficult to combine data, Liangzhu becomes a personal digital assistant with Internet messaging functions. The concept of such things is endless. Lift. At present, because the processing speed of the central processing unit of these electronic devices is limited, and their information storage space is also limited by the lack of memory capacity, they cannot provide consumers with faster and richer information. On electronic devices, the existing hardware equipment is used to compress a large amount of data stored and received more effectively to increase its storage space and make up for the lack of its memory capacity. When using such data, it can quickly Decompression to effectively improve its operating efficiency has become an important issue for the design and manufacturing of electronic products. At this stage, the processing speed of the central processing unit of the PDA product is relatively slow. The square calculation is implemented by software. If only integer-level data is needed in the product, then the floating-point function library is used for calculation. Requirements and consumes resources of the host. For example, in a palm-type electronic product generally equipped with an electronic map, the road name is marked by first finding the length of the road, and then uniformly distributing the name of the road on the line segments of the road. According to the traditional method, the length of the road is calculated using the square root function of the floating-point function library. However, when there are many roads, many accurate square root operations are required, and in the end, only the square root closest to the square root can be obtained. Integer, and test results show that its slower speed > does not achieve the effect of satisfying users. (Please read the notes on the back first

--線· 本紙張尺度適用中國國家標準(CNS)A4規格(210 X 297公釐) 548533 A7 B7 經濟部智慧財產局員工消費合作社印製 五、發明說明(2 ) 發明綱要: 有鑑此前述傳統PDA產品在計算開平方運算時,所發生之諸多缺點。本發 明乃根據一序歹[]整數分別加上0.5,再予平方後,其所得之平方數之整數値所形 成之數列,具有兩級等差數列之特性,並利用此一特性,在一電子產品中,針對 其上所安裝之一可進行開平方運算處理之程式中,以其實際需要之平方根之最大 範圍,建立一序列整數數列之平方數所形成之一索引對照表,俾該電子產品針對 所輸入之一平方數,進行開平方運算時,可透過查找該對照表,確定其試探起始 數及數列增量,利用窮舉循環運算法,經少量之加法運算,計算出最接近其平方 根之整數。 本發明之主要目的,係在尋求一種簡單快速之方法,令一電子產品在進行 開平方運算處理過程中,可迅速取得一最接近其平方根之整數,避免電子產品因 進行不必要之運算,造成資源上無謂之浪費,有搬昇運算速度。 圖示說明: 第1圖所示爲本發明之整體流程示意圖; 第2圖所示爲索引對照表中各數據之製作流程示意圖; 第3圖所不爲確定試探起始數之流程示意圖; 第4圖所示爲利用窮舉循環運算法求整數平方根之流程示意圖。 詳細說明: 本發明之主要理論根據,係在一序列之整數分別加上〇·5,再予平方後,其 所得之平方數之整數値所形成之數列,具有兩級等差數列之特性,本發明即利用 此一特性,藉計算出一不大於某一平方數之最大數値,俾以所算得之該數値作爲 一預期之計算結果。例如:在[(32+0·5)2】=1〇56、[(33+0·5)2Μΐ22、…等一序列 -3- 本紙張尺度適用中國國家標準(CNS)A4規格(210 X 297公爱) (請先閱讀背面之注意事項再本頁)--Line · This paper size applies to China National Standard (CNS) A4 (210 X 297 mm) 548533 A7 B7 Printed by the Consumer Cooperatives of the Intellectual Property Bureau of the Ministry of Economic Affairs 5. Description of the invention (2) Outline of the invention: Many disadvantages of traditional PDA products occur when calculating the square root operation. The present invention is based on a sequence of 歹 [] integers plus 0.5 respectively, and then squaring, and the resulting sequence of squared integers 値 has the characteristics of a two-level equal difference sequence, and uses this characteristic to In an electronic product, an index comparison table formed by the square number of a sequence of integer sequences is established based on the maximum range of the square root that it actually needs in a program that can be squared and calculated on one of the programs installed on it. When the product performs square root operation on one of the input square numbers, it can look up the comparison table to determine its trial starting number and sequence increment, and use the exhaustive loop algorithm to calculate the closest value through a small number of addition operations. An integer whose square root. The main purpose of the present invention is to find a simple and fast method, so that an electronic product can quickly obtain an integer closest to its square root during the square root operation process, so as to prevent electronic products from performing unnecessary calculations, resulting in There is no need to waste resources, and the speed of operation is increased. Illustration: Figure 1 shows the overall process of the present invention; Figure 2 shows the process of making each data in the index comparison table; Figure 3 does not show the process of determining the initial number of trials; Figure 4 shows a schematic diagram of the process of finding the square root of an integer using the exhaustive loop algorithm. Detailed explanation: The main theoretical basis of the present invention is that a sequence of integers in a sequence is added by 0.5, and then squared. The resulting sequence of integers 平方 of the squared number has the characteristics of a two-level equal difference series. The present invention uses this characteristic to calculate a maximum number 値 which is not greater than a certain square number, and uses the calculated number 値 as an expected calculation result. For example: a sequence of [(32 + 0 · 5) 2] = 1〇56, [(33 + 0 · 5) 2Μ… 22, ... etc. -3- This paper standard applies to China National Standard (CNS) A4 specification (210 X (297 public love) (Please read the precautions on the back before this page)

· -線· 548533 A7 B7 五、發明說明(n ) 之平方數之整數値所形成之數列中,Μ表示不大於X之最大整數,故大於1056 且小於1122之:平方數,應可開平方得到最接近平方根之整數33。按,一序列整 數分S咖上〇·5,再予平方後,其平方數之整數數列,可以下列公式計算出: = [(^ + 〇·5)2] = η2+η, (1-1) 此時,該平方數之整數數列中,序列上相鄰之二平方數間之公差値即爲: R} = 丨-& = 2/7 + 2 · (1-2) 故欲針對一所輸入之平方數α,計算出與其對應之一平方根之最小整數/1時,該 最小整數"即必需符合下列之運算條件·· η2 + η > a 〇 (1-3) 在本發明中,爲了確定(1_3)中之未知數/1,可採用窮舉循環運算法,對其進 行試探性運算,以求得其結果,該窮舉循環運算法係先藉尋找一試探起始數%·, 以一大於1056且小於1122之平方ifc爲例,若其數値大於所設定之一索弓丨對照表 中最大之平方數,則可先將該平方數之數値縮小100倍,並取其整數,得到其虛 擬之平方數爲10或11,再自該對照表中,依該虛擬平方數,由該對照表中最大 之一平方數開始尋找,直到尋找到第一個小於該虛擬平方數之序號3爲止,由於 先前已將該平方數縮小了 100倍,此時,即必需將所求得之該序號擴大10倍, 得到其起始平方數+1)=302 +30 = 930,並藉設定一增量2*(仏 +1)=2X30 + 2 = 62 »作爲其在一整數數列中,相鄰一平方數間之公差値’利用窮 舉循環運算法,力口以計算,如此,僅需三次循環運算,即可輕易得到計算結果, 找出最接近其平方根之整數π=33 〇 本發明即拫據前述序列整數分別加上0·5,再予平方後,其平方數之整數値 所形成之數列,具有兩級等差數列之特性,在一電子產品中,針對其上所安裝之 一可進行開平方運算處理之程式中,以其實際需要之平方根之最大範圍,建立一 -4- 本紙張尺度適用中國國家標毕(CNS)A4規格(210 X 297公釐) (請先閱讀背面之注意事項再· -Line · 548533 A7 B7 V. Description of the invention (n) In the sequence formed by the integer 平方 of the square number, M represents the largest integer not greater than X, so greater than 1056 and less than 1122: the square number should be squared Get the nearest integer 33. According to, a sequence of integers is divided into 0.5, and after squaring, the integer sequence of the squares can be calculated by the following formula: = [(^ + 〇 · 5) 2] = η2 + η, (1- 1) At this time, in the integer sequence of the square number, the tolerance between two adjacent square numbers in the sequence 値 is: R} = 丨-& = 2/7 + 2 · (1-2) When an input square number α is used to calculate the minimum integer / 1 corresponding to a square root, the minimum integer " must meet the following calculation conditions ... η2 + η > a 〇 (1-3) In the invention, in order to determine the unknown number / 1 in (1_3), an exhaustive loop algorithm can be used to perform a tentative operation to obtain the result. The exhaustive loop algorithm first finds a trial starting number. % · , Take a square ifc greater than 1056 and less than 1122 as an example. If the number 値 is larger than the maximum square number set in the comparison table, the number of squares 値 can be reduced by 100 times first. And take its integer to get the virtual square number of 10 or 11, and then from the comparison table, according to the virtual square number, the largest one in the comparison table is squared Start searching until you find the first serial number 3 that is less than the virtual square number. Because the square number has been reduced by 100 times previously, at this time, you must expand the obtained serial number by 10 times to get its starting number. Starting square number +1) = 302 +30 = 930, and by setting an increment 2 * (仏 +1) = 2X30 + 2 = 62 »as its tolerance in an integer sequence between adjacent square numbers 平方'Using the exhaustive loop algorithm to calculate by force. In this way, only three loop operations are required to easily obtain the calculation result, and find the integer closest to its square root π = 33. The present invention is to add the integers according to the aforementioned sequence. After 0,5, and then squaring, the sequence formed by the integer 値 of the square number has the characteristics of two-level equal difference sequence. In an electronic product, the square root operation can be performed on one of the electronic products installed on it. In the program, the maximum range of the square root of its actual needs is used to establish a 4- This paper size is applicable to China National Standard Complete (CNS) A4 specification (210 X 297 mm) (Please read the precautions on the back before

-1線. 經濟部智慧財產局員工消費合作社印製 548533 A7 B7 經濟部智慧財產局員工消費合作社印製 五、發明說明) 序列整數數列之平方數所形成之一索弓丨對照表,俾該電子產品針對所輸入之一平 方數,進行開平方運算時,可透過查找該對照表’確定其試探起始數及數列增量, 以利用窮舉循環運算法,請參閱第1圖所示,經少量之加法運算,計算出最接近 該整數之平方根。故,本發明在進行整數快速開平方時,其處理步驟,主要包括 三大部分,第一部分係建立該索弓丨對照表,第二部分係確定該試探起始數,第三 部分則係根據該起始數,利用窮舉循環運算法,計算出最接近之平方根。 爲令本發明之方法所採取之處理程序及所達成之功效,能更具體且明確,茲 特列舉一較佳實施例,配合附圖,詳說明如下: 在某一安裝有電子地圖之電子產品中,若欲在該電子地圖所顯示之一條道路 上均勻地標註路名,則需先計算出該條道路之長度,傳統上’計算兩點 A(X!,%)和B(X2.,少2)間之距離之計算公式爲: V(X1 — Χ 2 ) 2 + (少1 - 少2)2 該公式係手[_]用該電子產品中浮點函數庫之開平方函數,計算出該條路之長 度,惟,若其識數較多時,則需進行多次精確之開平方運算後,再取最接近其 平方根之整數,故其運算速度較慢。 本發明爲改進前述傳統運算上所發生之缺點,主要係先根據在該電子產品上 使用該電子地圖時,實際需要之平方根之最大範圍(即該電子地圖上所顯示之最 大距離),依第2圖所示之製作流程,建立一整數數列之平方數之索弓丨對照表, 其運算步驟如下: (1) 首先,讀取實際需要之平方根之最大範圍値SQRTTABLEN,若該平方根之 輸入範圍値較大時,可將該數値縮小10倍; (2) 初始化該對照表中儲存數據之組數i =Η4,i =〇 ; (3) 逐~計算出該對照表SqrtTab[i】中欲儲存之數據SqrtTab[i】=i * i,並以其平 (請先閱讀背面之注意事項再本頁)-1 line. Printed by the Consumer Cooperative of the Intellectual Property Bureau of the Ministry of Economic Affairs 548533 A7 B7 Printed by the Consumer Cooperative of the Intellectual Property Bureau of the Ministry of Economic Affairs. When the electronic product performs square root operation on one of the input square numbers, it can find the starting number of trials and the increment of the sequence by looking up the lookup table to use the exhaustive loop algorithm. Please refer to Figure 1, After a small amount of addition, the square root closest to the integer is calculated. Therefore, in the present invention, when performing integer square rooting, its processing steps mainly include three major parts. The first part is to establish the cable bow comparison table, the second part is to determine the starting number of the trial, and the third part is based on This starting number uses the exhaustive loop algorithm to calculate the nearest square root. In order to make the processing procedure adopted and the effect achieved by the method of the present invention more specific and clear, here is a preferred embodiment, which is described in detail with the accompanying drawings as follows: An electronic product equipped with an electronic map If you want to label road names evenly on one of the roads displayed on the electronic map, you must first calculate the length of the road. Traditionally, the two points A (X!,%) And B (X2., The formula for calculating the distance between 2) is: V (X1 — χ 2) 2 + (less 1-less 2) 2 This formula is calculated by using the squared function of the floating-point function library in this electronic product. Find out the length of the path, but if it has a large number of digits, it needs to perform multiple precise square root operations and then take the integer closest to its square root, so its operation speed is slower. The present invention is to improve the disadvantages that occur in the traditional calculations described above. It is mainly based on the maximum range of the square root actually required when the electronic map is used on the electronic product (that is, the maximum distance displayed on the electronic map). The production process shown in Figure 2 is to create a cable bow of the square number of an integer sequence. 丨 The comparison procedure is as follows: (1) First, read the maximum range of the square root that actually needs 値 SQRTTABLEN. If the input range of the square root is When 値 is large, the number 将该 can be reduced by 10 times; (2) Initialize the number of groups of data stored in the lookup table i = Η4, i = 0; (3) Calculate the lookup table SqrtTab [i] one by one. Data to be stored SqrtTab [i] = i * i, and flatten it (please read the precautions on the back before this page)

'丨線- 本紙張尺度適用中國國家標準(CNS)A4規格(210 X 297公釐) 548533 A7 B7 五、發明說明) 方根作爲序號; (4)若i < SQRTTABLEN,重複步驟(3);否則,結束。 根據前述步驟,若在該實施例之電子地圖上,不同位置兩點間之距離,其所 需之最大値,實際上不大於30時,爲令所建立之一索引對照表較小,可取0到 31間之整數作爲平方根,建立該索引對照表,若實際需要之整數平方根比較大 時,該對照表會變得比較大,此時,僅需將最大之整數平方根縮小10倍即可。 在該實施例中,可先定義該輸入平方根之最大範圍値SQRTTABLEN如下: #defme SQRTTABLEN 31 再依前述步驟製儒索引對照表如下: {〇, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961}; 對輸入過大之最大範圍値,如其平方數大於(31xl〇)2 =96100,僅需顯示輸 入平方根之最大範圍値爲錯誤即可,事實上,該等數値在該實施例之實際運作中, 並不會出現。 其次,本發明需確定在使用該電子地圖時,實際需要之試探起始數,如第3 圖所示之流程,當該電子產品針對所輸入之一平方數,進行開平方運算時,若判 斷其係大於所建立之該對照表中最大之數値,可先用1〇〇整除,令其平方數縮小 100倍’並依下歹丨涉驟,將其標註一 nBitCount之鶴己: nBitCount = 0; if開平方數> 961 then 開平方數=開平方數/1〇〇; nBitCount = 1; 本紙張尺度適用中國國家標準(CNS)A4規格(210 X 297公釐) (請先閱讀背面之注意事項再^寫本頁)'丨 Line-This paper size is in accordance with China National Standard (CNS) A4 (210 X 297 mm) 548533 A7 B7 V. Description of the invention) Square root as the serial number; (4) If i < SQRTTABLEN, repeat step (3) ; Otherwise, the end. According to the foregoing steps, if the distance between two points in different positions on the electronic map of this embodiment is required to be the largest 値, which is actually not greater than 30, in order to make one of the index comparison tables smaller, 0 may be taken. The integer between 31 and 31 is used as the square root to establish the index lookup table. If the square root of the integer that is actually needed is relatively large, the lookup table will become larger. At this time, it is only necessary to reduce the maximum square root of the integer by 10 times. In this embodiment, the maximum range of the square root of the input can be defined first: SQRTTABLEN is as follows: #defme SQRTTABLEN 31 According to the foregoing steps, the index comparison table is created as follows: {〇, 1, 4, 9, 16, 25, 36, 49 , 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961}; If the maximum range of the input is too large, if its square number is greater than (31xl0) 2 = 96100, it is only necessary to display the maximum range of the input square root, which is an error. In fact, these numbers are in the actual operation of this embodiment. Does not appear. Secondly, the present invention needs to determine the actual starting number of trials when using the electronic map, as shown in the flow chart in Figure 3. When the electronic product performs a square root operation on one of the input square numbers, if it is judged It is greater than the largest number in the established lookup table. It can be divided by 100 to reduce the square number by 100 times' and follow the steps below to label it with an nBitCount: nBitCount = 0; if squared number> 961 then squared number = squared number / 1〇〇; nBitCount = 1; This paper size is applicable to China National Standard (CNS) A4 (210 X 297 mm) (Please read the back first (Notes again ^ write this page)

-1線· 經濟部智慧財產局員工消費合作社印製 548533 A7 B7 經濟部智慧財產局員工消費合作社印製 五、發明說明(β ) end if; 再自所建立之該對照表SqrtTab中最後一個數値,向前開始尋找第一個不大 於該平方數之數値,並依下列步驟,尋找其在該對照表中之序號, nlndex = SQRTTABLEN; while nlndex >= 0 and 開平方數 >=SqrtTab[nIndex】 do nlndex = nlndex -1; end while; 嗣再依下列步驟,根據nBitCoimt之標記,將所找到之序號乘以10 : if nBitCount > 0 then nlndex = nlndex * 10; end if; 如此,在該實施例之電子地圖上,若一條道路兩端點之橫座標差爲31,縱座 標差爲12,當欲對該二端點間距離之平方數312 +122 =1105,進行開平方運算 時,若判斷其係大於所建立之該對照表中最大之數値時,可將該開平方數先除以 1〇〇,取其整數,得其虛擬之平方數爲11,並將其標註一 nBitCount = 1之標記; 再從對照表SqrtTab中,尋找其在該對照表中之序號nlndex,得到nlndex = 3 ; 嗣,再根據nBitCount之標記,得到其試探起始數爲nlndex = 30 〇 最後,本發明再根據所計算出之試探起始數,利用循環窮舉運算法,參閱第 4圖所示,依下列步驟加以計算: nStartData = nlndex * (nlndex + 1); nlncrData = 2 * (nlndex + 1); while nStartData < 開平方數 do nStartData = nStartData + nlncrData; nlncrData = nlncrData + 2; ____-7- 本紙張尺度適用中國國家標準(CNS)A4規格(210 x 297公釐) (請先閱讀背面之注意事項再本頁)-1 Line · Printed by the Consumer Cooperatives of the Intellectual Property Bureau of the Ministry of Economic Affairs 548533 A7 B7 Printed by the Consumer Cooperatives of the Intellectual Property Bureau of the Ministry of Economic Affairs 5. Description of the invention (β) end if;値, start looking for the first number not greater than the square number 値, and follow the steps below to find its serial number in the lookup table, nlndex = SQRTTABLEN; while nlndex > = 0 and square number > = SqrtTab [nIndex] do nlndex = nlndex -1; end while; 嗣 Follow the steps below and multiply the found number by 10 according to the nBitCoimt mark: if nBitCount > 0 then nlndex = nlndex * 10; end if; so In the electronic map of this embodiment, if the horizontal coordinate difference between the two ends of a road is 31 and the vertical coordinate difference is 12, when the square number of the distance between the two endpoints is 312 +122 = 1105, square the square. During the calculation, if it is judged that it is greater than the largest number in the established comparison table, the squared number may be divided by 100 first, and an integer may be taken to obtain a virtual squared number of 11. Mark a flag with nBitCount = 1; From the lookup table SqrtTab, find its serial number nlndex in the lookup table, and get nlndex = 3; 再, and then according to the nBitCount mark, get the initial number of trials nlndex = 30. Finally, the present invention calculates according to the calculated The trial starting number is calculated using the cyclic exhaustive algorithm, as shown in Figure 4, and calculated according to the following steps: nStartData = nlndex * (nlndex + 1); nlncrData = 2 * (nlndex + 1); while nStartData < Square number do nStartData = nStartData + nlncrData; nlncrData = nlncrData + 2; ____- 7- This paper size applies to China National Standard (CNS) A4 (210 x 297 mm) (Please read the precautions on the back before this page) )

訂: 線· 548533 A8 B8 C8 D8 力、申請專利範圍 nlndex = nlndex + 1; end while; 在該電子地圖中,其試探起始數nlndex = 30,其循環運算之啓始數値 nStartData = 30 * (30 + 1) = 930,循環增量 nlncrData = 2 * (30 + 1) = 62,由於 該啓始數値nStartData係小於開平方數1105,故透過前述循環運算之過程,當 nlndex = 33時,該數値nStartData = 1120即大於該開平方數1105,此時,即結 束循環運算,其所計算出之結果nIndeX= 33,即爲最接近其平方根之整數。 利用本發明之方法,在進行整數開平方之運算時,經實驗驗證本發明之開 平方運算法之運算效率,約爲利用傳統浮點庫函數之8倍,故本發明之方法確實 可令該電子產品在進行開平方運算處理過程中,迅速取得一最接近其平方根之整 數’避免該電子產品因進行不必要之運算,造成資源上無謂之浪費,有效提昇其 開平方運算之速度。 以上所述,僅爲本發明方法之較佳實施例而已,惟,並非用以限定本發明方 法之範圍。按,凡熟悉該項技術人士,依據本發明所揭露之技術內容,在其它未 脫離本發明所揭示之精神下所完成之等效改變或修飾,均應包含在下述之申請專 利範圍內。 (請先閱讀背面之注意事項再 · ! 本頁. 經濟部智慧財產局員工消費合作社印製 本紙張尺度適用中國國家標準(CNS)A4規格(210 X 297公釐)Order: Line · 548533 A8 B8 C8 D8 force, patent application scope nlndex = nlndex + 1; end while; In this electronic map, the trial starting number nlndex = 30, and the starting number of its loop operation 値 nStartData = 30 * (30 + 1) = 930, the loop increment nlncrData = 2 * (30 + 1) = 62, because the starting number 値 nStartData is less than the square root number 1105, so through the process of the foregoing loop operation, when nlndex = 33 The number 値 nStartData = 1120 is greater than the squared number 1105. At this time, the loop operation is ended, and the calculated result nIndeX = 33 is the integer closest to its square root. By using the method of the present invention, when performing the operation of integer squared, it is experimentally verified that the operation efficiency of the squared algorithm of the present invention is about 8 times that of the traditional floating-point library function. Therefore, the method of the present invention can indeed make the In the process of performing the square root operation, the electronic product quickly obtains an integer closest to its square root. This prevents the electronic product from performing unnecessary calculations, causing unnecessary waste of resources, and effectively increasing the speed of the square root operation. The above description is only a preferred embodiment of the method of the present invention, but it is not intended to limit the scope of the method of the present invention. According to those skilled in the art, any equivalent changes or modifications made in accordance with the technical content disclosed in the present invention without departing from the spirit disclosed in the present invention should be included in the scope of the patent application described below. (Please read the precautions on the back first! This page. Printed by the Consumer Cooperatives of the Intellectual Property Bureau of the Ministry of Economic Affairs This paper is sized for China National Standard (CNS) A4 (210 X 297 mm)

Claims (1)

548533548533 六 申請專利範圍 1、 整數快速開平方之方法,主要係在一電子產品中,針對其上所安裝之一 可進行開平方運算處理之程式,依其實際需要之平方根之最大範圍’以一序列整 數"分別加上0.5,再予平方後,其所得之平方數之整數値所形成之下列數列 {^}: = [(^ + 0.5)2] = n2^n , 具有兩級等差數列之特性,建立一序列整數數列之平方數之一索弓丨對照表, 俾該電子產品針對所輸入之一平方數,進行開平方運算處理時,可透過查找該對 照表,確定其試探起始數〜及序列上相鄰之二平方數間之公差値: {《}二 U = 2m2 , 最後,再利用窮舉循環運算法,計算出最接近其平方根之整數。 2、 如申請專利範圍第1項所述之整數快速開平方之方法,其中該索弓丨對照 表係依電子產品上實際需要之平方根之最大範圍,依下列步驟計算出該對照表中 之一序列整數數列之平施·· 首先,讀取所輸入之該平方根之最大範圍値’若該平方根之範圍値較實際 需要讎大時,可將該數ί麵小一定之整數倍; 初始化該對照表中儲存_之組數; 逐一計算出該對照表中欲儲存之該整數數列之平方數,並以其平方根作爲 序號; 經濟部智慧財產局員工消費合作社印製 直到該對照表中儲存數據之組數大於該平方根之最大範圍値爲止。 3、 如申請專利範圍第1項所述之整數快速開平方之方法,其中當所輸入之 該平方根之最大範圍値,過大於實際需要値時,該電子產品僅需顯示輸入之平方 根之最大範圍値爲錯誤即可。 4、 如申請專利範圍第2項所述之整數快速開平方之方法,其中該實際需要 本紙張尺度適用中國國家標準(CNS)A4規格(210 X 297公釐) 548533 A8 B8 C8 D8 六、申請專利範圍 之平方根之最大範圍可爲該電子裝置上所顯示之最大距離。 (請先閱讀背面之注意事項再本頁) 5、 如申請專利範圍第2項所述之整數快速開平方之方法,其中該可進行開 平方運算處理之程式可爲一電子地圖之程式。 6、 如申請專利範圍第5項所述之整數快速開平方之方法,其中該實際需要 之平方根之最大範圍可爲該電子地圖上所顯示之最大距離。 7、 如申請專利範圍第2、3、4、5或ό項所述之整數快速開平方之方法,其 中該一定之整數倍可爲10。 8、 如申請專利範圍第1、2、3、4、5或6項所述之整數快速開平方之方法, 其中該試探起始數係依下列步驟計算出: 首先,對於所輸入之平方數,若判斷其係大於所建立之該對照表中最大之數 値,可用一定之整數倍予以整除,令其平方數縮小另一整數倍,並將其標註一標 記; 再自所建立之該對照表中最後一個數値,向前開始尋找第一個不大於該平方 數之數値,並尋找其在該對照表中之序號; 嗣再根據該標記,將所找到之序號乘以該另一整數倍,即得到該試探起始數 線· Πι 0 經濟部智慧財產局員工消費合作社印製 9、 如申請專利範圍第8項所述之整數快速開平方之方法,其中該循環窮舉 運算法係以該試探起始數A,設定其循環運算之啓始數値Ά,· + 1),並依其循 環增量2 * (Λ/ + 1),利用力口法循環運算,直到所計算出之數値大於該輸入之平方 數時,始結束循環運算,此時所計算出之結果,即爲最接近其平方根之整數。 10、 如申請專利範圍第9項所述之整數快速開平方之方法,其中該另一整數 倍可爲100。 -10 - 本紙張尺度適用中國國家標準(CNS)A4規格(210 X 297公釐)6. Application for Patent Scope 1. The method of fast square root of an integer is mainly used in an electronic product to perform a square root operation program on one of the electronic products installed, according to the maximum range of the square root of its actual needs. Integer " add 0.5 respectively, and after squaring, the following sequence formed by the integer 値 of the squared number {^}: = [(^ + 0.5) 2] = n2 ^ n has a two-level equal difference sequence Characteristics of a series of integers of a series of squares, a cable bow 丨 comparison table, 俾 the electronic product for one of the square number input, square root calculation processing, you can look up the comparison table to determine the beginning of the test The number ~ and the tolerance between two adjacent square numbers in the sequence 序列: {"} U = 2m2, and finally, the exhaustive loop algorithm is used to calculate the integer closest to its square root. 2. The method of fast squared integer as described in item 1 of the scope of patent application, wherein the cable bow comparison table is based on the maximum range of the square root actually required on the electronic product, and one of the comparison tables is calculated according to the following steps. First, read the maximum range of the square root you entered. 'If the range of the square root is larger than the actual need, you can reduce the number to a certain integer multiple; initialize the comparison. The number of groups stored in the table; Calculate the square number of the integer sequence to be stored in the comparison table one by one, and use its square root as the serial number; printed by the employee consumer cooperative of the Intellectual Property Bureau of the Ministry of Economic Affairs until the data stored in the comparison table The number of groups is larger than the maximum range of the square root. 3. The method of fast square root of integer as described in item 1 of the scope of patent application, wherein when the maximum range of the square root entered is too large, which is greater than the actual need, the electronic product only needs to display the maximum range of the square root entered.値 is wrong. 4. The method of fast squared by integer as described in item 2 of the scope of patent application, where the actual requirement is that the paper size applies the Chinese National Standard (CNS) A4 specification (210 X 297 mm) 548533 A8 B8 C8 D8 VI. Application The maximum range of the square root of the patent range may be the maximum distance displayed on the electronic device. (Please read the precautions on the back first, then this page) 5. The method of fast square root of integer as described in item 2 of the scope of patent application, wherein the program that can perform square root calculation can be an electronic map program. 6. The method of fast square root of integer as described in item 5 of the scope of patent application, wherein the maximum range of the square root actually required can be the maximum distance displayed on the electronic map. 7. The method for fast squared integers as described in item 2, 3, 4, 5, or 6 of the scope of patent application, where the certain integer multiple may be 10. 8. The method for fast squared integers as described in item 1, 2, 3, 4, 5, or 6 of the scope of the patent application, wherein the initial number of trials is calculated according to the following steps: First, for the input square number If it is judged that it is greater than the largest number in the established comparison table, it can be divided by a certain integer multiple to reduce its square number by another integer multiple and mark it with a mark; then from the established comparison The last number in the table, looking forward to find the first number not greater than the square number, and find its serial number in the comparison table; 嗣 then multiply the found serial number by the other Integer multiples, that is, the starting number line of the test. Πι 0 Printed by the Consumer Cooperatives of the Intellectual Property Bureau of the Ministry of Economic Affairs. 9. The method of fast squared integers as described in item 8 of the scope of patent application. Based on the trial starting number A, set the starting number of its loop operation 运算, · + 1), and according to its loop increment 2 * (Λ / + 1), use the force mouth method to loop the calculation until the calculated The number 値 is greater than the square of the input At this time, the loop operation starts and ends, and the result calculated at this time is the integer closest to its square root. 10. The method of fast squared by an integer as described in item 9 of the scope of the patent application, wherein the other integer multiple may be 100. -10-This paper size applies to China National Standard (CNS) A4 (210 X 297 mm)
TW89127387A 2000-12-20 2000-12-20 Method for fast calculating the square root of integers TW548533B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW89127387A TW548533B (en) 2000-12-20 2000-12-20 Method for fast calculating the square root of integers

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW89127387A TW548533B (en) 2000-12-20 2000-12-20 Method for fast calculating the square root of integers

Publications (1)

Publication Number Publication Date
TW548533B true TW548533B (en) 2003-08-21

Family

ID=29997810

Family Applications (1)

Application Number Title Priority Date Filing Date
TW89127387A TW548533B (en) 2000-12-20 2000-12-20 Method for fast calculating the square root of integers

Country Status (1)

Country Link
TW (1) TW548533B (en)

Similar Documents

Publication Publication Date Title
Liu et al. Design and analysis of inexact floating-point adders
US20150379682A1 (en) Vertex attribute data compression with random access using hardware
CN104603744A (en) Operations for efficient floating point computations
EP2945126A2 (en) Graphics processing method and graphics processing apparatus
CN108874765A (en) Term vector processing method and processing device
CN110675479A (en) Dynamic illumination processing method and device, storage medium and electronic device
CN110619112B (en) Pronunciation marking method and device for Chinese characters, electronic equipment and storage medium
CN116466910A (en) Floating point number-based table lookup method and device, electronic equipment and storage medium
TW548533B (en) Method for fast calculating the square root of integers
CN105320641B (en) Text verification method and user terminal
CN102622359B (en) Method and device for searching character strings in database
WO2024124843A1 (en) Data processing method and apparatus, and device and readable storage medium
US8625901B2 (en) Method for dynamically adjusting a waiting time of handwriting inputs, electronic equipment and computer-readable medium thereof
WO2024066271A1 (en) Database watermark embedding method and apparatus, database watermark tracing method and apparatus, and electronic device
CN107688661B (en) Lyric similarity calculation method, terminal device and computer-readable storage medium
CN107742315B (en) Method and device for generating character word cloud portrait
US20180350121A1 (en) Global annotations across contents
CN104199619A (en) Method and device for processing data in NAND
CN106843520A (en) Method and apparatus for exporting whole sentence
CN113626635A (en) Song phrase dividing method, system, electronic equipment and medium
CN113283233A (en) Text error correction method and device, electronic equipment and storage medium
CN113157964A (en) Method and device for searching data set through voice and electronic equipment
WO2023272499A1 (en) Encoding method, decoding method, apparatus, terminal device, and readable storage medium
TW201312375A (en) Method and system for inputting Chinese character with unknown pronunciation using pinyin input method
US11211945B1 (en) Parallelized decoding of variable-length prefix codes

Legal Events

Date Code Title Description
GD4A Issue of patent certificate for granted invention patent