內容列表(Table of Contents)


8. 選用的雙數值詞集(The optional Double-Number word set)

參閱(See): A.8 選用的雙數值詞集(The optional Double-Number word set)


8.1 簡介(Introduction)

十六位元 Forth 系統經常使用雙長度數字. 然而, 許多在小型內嵌式系統的 Forth 並不會, 而許多在一個單元大小為 32 位元的 Forth 使用者會發現大量減少使用雙長度數字. 因此操作雙長度實體的詞就被放在這選用詞集了.

Sixteen-bit Forth systems often use double-length numbers. However, many Forths on small embedded systems do not, and many users of Forth on systems with a cell size of 32 bits or more find that the use of double-length numbers is much diminished. Therefore, the words that manipulate double-length entities have been placed in this optional word set.


8.2 附加的專有名詞和記號(Additional terms and notation)

無(None).


8.3 附加的使用需求(Additional usage requirements)


8.3.1 環境的詢問(Environmental queries)

將表格 8.1 加進表格 3.5.

Append table 8.1 to table 3.5.

參閱(See): 3.2.6 環境的詢問(Environmental queries)

表格 8.1 - 環境詢問字串

字串            值    資料型別   常數?       意義
------         ---------------   ---------   -------
DOUBLE          flag             no          雙數值詞集存在
DOUBLE-EXT      flag             no          雙數值延伸詞集存在

Table 8.1 - Environmental Query Strings

String         Value data type   Constant?   Meaning
------         ---------------   ---------   -------
DOUBLE          flag             no          double-number word set present
DOUBLE-EXT      flag             no          double-number extensions word set present


8.3.2 文字解譯器數字轉換(Text interpreter input number conversion)

當文字解譯器處理一個立即地跟隨一個小數點的數字並且找不到它是一個定義名稱時, 文字解譯器必須將它轉換成一個雙單元數字.

When the text interpreter processes a number that is immediately followed by a decimal point and is not found as a definition name, the text interpreter shall convert it to a double-cell number.

例如, 輸入 DECIMAL 1234 會留下單一單元數字 1234 在堆疊上, 而輸入 DECIMAL 1234. 會留下雙單元數字 1234 0 在堆疊上.

For example, entering DECIMAL 1234 leaves the single-cell number 1234 on the stack, and entering DECIMAL 1234. leaves the double-cell number 1234 0 on the stack.

參閱(See): 3.4.1.3 文字解譯器數字轉換(Text interpreter input number conversion), RFI 0004 數字轉換(Number Conversion).


8.4 附加的文件需求(Additional documentation requirements)


8.4.1 系統文件(System documentation)


8.4.1.1 實作自訂選項(Implementation-defined options)


8.4.1.2 模稜兩可的情況(Ambiguous conditions)


8.4.1.3 其他的系統文件(Other system documentation)


8.4.2 程式文件(Program documentation)


8.5 遵守標準和命名(Compliance and labeling)


8.5.1 ANS Forth 系統(ANS Forth systems)

措辭 提供雙數值詞集 必須被加到任何提供雙數值詞集的標準系統的描述之中.

The phrase Providing the Double-Number word set shall be appended to the label of any Standard System that provides all of the Double-Number word set.

措辭 從雙數值延伸詞集提供 name(s) 必須被加到任何提供部分雙數值延伸詞集的標準系統的描述之中.

The phrase Providing name(s) from the Double-Number Extensions word set shall be appended to the label of any Standard System that provides portions of the Double-Number Extensions word set.

措辭 提供雙數值延伸詞集 必須被加到任何提供所有雙數值詞集和雙數值延伸詞集的標準系統的描述之中.

The phrase Providing the Double-Number Extensions word set shall be appended to the label of any Standard System that provides all of the Double-Number and Double-Number Extensions word sets.


8.5.2 ANS Forth 程式(ANS Forth programs)

措辭 需要雙數值詞集 必須被加到任何需要系統提供雙數值詞集的標準程式的描述之中.

The phrase Requiring the Double-Number word set shall be appended to the label of Standard Programs that require the system to provide the Double-Number word set.

措辭 需要雙數值延伸詞集中的 name(s) 必須被加到任何需要系統提供部分雙數值延伸詞集的標準程式的描述之中.

The phrase Requiring name(s) from the Double-Number Extensions word set shall be appended to the label of Standard Programs that require the system to provide portions of the Double-Number Extensions word set.

措辭 需要雙數值延伸詞集 必須被加到任何需要系統提供所有雙數值和雙數值延伸詞集的標準程式的描述之中.

The phrase Requiring the Double-Number Extensions word set shall be appended to the label of Standard Programs that require the system to provide all of the Double-Number and Double-Number Extensions word sets.


8.6 詞彙表(Glossary)


8.6.1 雙數值詞(Double-Number words)


8.6.1.0360 2CONSTANT
雙-常數 DOUBLE
	( x1 x2 "<spaces>name" -- )

跳過開頭的空白分界符號. 分析出由一個空白分界的 name. 為 name 創造一個有以下執行語義的定義.

name 將會被參考為 雙-常數 .

        name 執行: ( -- x1 x2 )

將單元對 x1 x2 放置於堆疊.

參閱: 3.4.1 分析, A.8.6.1.0360 2CONSTANT


8.6.1.0360 2CONSTANT
two-constant DOUBLE
	( x1 x2 "<spaces>name" -- )

Skip leading space delimiters. Parse name delimited by a space. Create a definition for name with the execution semantics defined below.

name is referred to as a two-constant.

        name Execution: ( -- x1 x2 )

Place cell pair x1 x2 on the stack.

See: 3.4.1 Parsing, A.8.6.1.0360 2CONSTANT


8.6.1.0390 2LITERAL
雙-文字 DOUBLE

        解譯: 這個詞的解譯語義是未定義的. 

	編譯: ( x1 x2 -- )

將下列的執行語義加進目前的定義.

        執行時期: ( -- x1 x2 )

將單元對 x1 x2 放置於堆疊上.

參閱: A.8.6.1.0390 2LITERAL


8.6.1.0390 2LITERAL
two-literal DOUBLE

        Interpretation: Interpretation semantics for this word are undefined.

	Compilation: ( x1 x2 -- )

Append the run-time semantics below to the current definition.

        Run-time: ( -- x1 x2 )

Place cell pair x1 x2 on the stack.

See: A.8.6.1.0390 2LITERAL


8.6.1.0440 2VARIABLE
雙-變數 DOUBLE
	( "<spaces>name" -- )

跳過開頭的空白分界符號. 分析出由一個空白分界的 name. 為 name 創造一個有以下執行語義的定義. 保留兩個連續的資料空間單元.

name 將會被參考為一個 雙-常數.

        name 執行: ( -- a-addr )

a-addr 是當 2VARIABLE 定義 name 時, 在資料空間保留的兩個連續單元的第一個單元(最低位址)的位址. 一個程式需負責初始化它的內容.

參閱: 3.4.1 分析, 6.1.2410 VARIABLE , A.8.6.1.0440 2VARIABLE


8.6.1.0440 2VARIABLE
two-variable DOUBLE
	( "<spaces>name" -- )

Skip leading space delimiters. Parse name delimited by a space. Create a definition for name with the execution semantics defined below. Reserve two consecutive cells of data space.

name is referred to as a two-variable.

        name Execution: ( -- a-addr )

a-addr is the address of the first (lowest address) cell of two consecutive cells in data space reserved by 2VARIABLE when it defined name. A program is responsible for initializing the contents.

See: 3.4.1 Parsing, 6.1.2410 VARIABLE , A.8.6.1.0440 2VARIABLE


8.6.1.1040 D+
d-加號 DOUBLE
	( d1|ud1 d2|ud2 -- d3|ud3 )

將 d2|ud2 加進 d1|ud1 得到結果 d3|ud3.


8.6.1.1040 D+
d-plus DOUBLE
	( d1|ud1 d2|ud2 -- d3|ud3 )

Add d2|ud2 to d1|ud1, giving the sum d3|ud3.


8.6.1.1050 D-
d-負號 DOUBLE
	( d1|ud1 d2|ud2 -- d3|ud3 )

從 d1|ud1 減去 d2|ud2, 得到差值 d3|ud3.


8.6.1.1050 D-
d-minus DOUBLE
	( d1|ud1 d2|ud2 -- d3|ud3 )

Subtract d2|ud2 from d1|ud1, giving the difference d3|ud3.


8.6.1.1060 D.
d-句點 DOUBLE
	( d -- )

以自由欄位格式顯示 d.


8.6.1.1060 D.
d-dot DOUBLE
	( d -- )

Display d in free field format.


8.6.1.1070 D.R
d-句點-r DOUBLE
	( d n -- )

以欄位為 n 個字元寬的方式顯示右對齊的 d. 如果需要用來顯示 d 的字元數目大於 n, 所有的數字會以必要的寬度來顯示出來, 而沒有開頭的空白.

參閱: A.8.6.1.1070 D.R


8.6.1.1070 D.R
d-dot-r DOUBLE
	( d n -- )

Display d right aligned in a field n characters wide. If the number of characters required to display d is greater than n, all digits are displayed with no leading spaces in a field as wide as necessary.

See: A.8.6.1.1070 D.R


8.6.1.1075 D0<
d-零-小於 DOUBLE
	( d -- flag )

在 d 小於零時 flag 為真.


8.6.1.1075 D0<
d-zero-less DOUBLE
	( d -- flag )

flag is true if and only if d is less than zero.


8.6.1.1080 D0=
d-零-等於 DOUBLE
	( xd -- flag )

如果 xd 等於零時, flag 為真.


8.6.1.1080 D0=
d-zero-equals DOUBLE
	( xd -- flag )

flag is true if and only if xd is equal to zero.


8.6.1.1090 D2*
d-雙-星號 DOUBLE
	( xd1 -- xd2 )

xd2 是將 xd1 向最大有效位元位移一個位元的結果, 將空出的最小有效位元填入零.

參閱: A.8.6.1.1090 D2*


8.6.1.1090 D2*
d-two-star DOUBLE
	( xd1 -- xd2 )

xd2 is the result of shifting xd1 one bit toward the most-significant bit, filling the vacated least-significant bit with zero.

See: A.8.6.1.1090 D2*


8.6.1.1100 D2/
d-雙-除號 DOUBLE
	( xd1 -- xd2 )

xd2 是將 xd1 向最小有效位元位移一個位元的結果, 保持最大有效位元不變.

參閱: A.8.6.1.1100 D2/


8.6.1.1100 D2/
d-two-slash DOUBLE
	( xd1 -- xd2 )

xd2 is the result of shifting xd1 one bit toward the least-significant bit, leaving the most-significant bit unchanged.

See: A.8.6.1.1100 D2/


8.6.1.1110 D<
d-小-於 DOUBLE
	( d1 d2 -- flag )

如果 d1 小於 d2, 則 flag 為真.


8.6.1.1110 D<
d-less-than DOUBLE
	( d1 d2 -- flag )

flag is true if and only if d1 is less than d2.


8.6.1.1120 D=
d-等於 DOUBLE
	( xd1 xd2 -- flag )

如果 xd1 每一個位元跟 xd2 相同, flag 為真.


8.6.1.1120 D=
d-equals DOUBLE
	( xd1 xd2 -- flag )

flag is true if and only if xd1 is bit-for-bit the same as xd2.


8.6.1.1140 D>S
d-到-s DOUBLE
	( d -- n )

n 是 d 的相等值. 如果 d 在 s 的一個有號單一單元數值的範圍之外時, 將會發生模稜兩可的情況.

參閱: A.8.6.1.1140 D>S


8.6.1.1140 D>S
d-to-s DOUBLE
	( d -- n )

n is the equivalent of d. An ambiguous condition exists if d lies outside the range of a signed single-cell number.

See: A.8.6.1.1140 D>S


8.6.1.1160 DABS
d-絕對值 DOUBLE
	( d -- ud )

ud 是 d 的絕對值.


8.6.1.1160 DABS
d-abs DOUBLE
	( d -- ud )

ud is the absolute value of d.


8.6.1.1210 DMAX
d-最大值 DOUBLE
	( d1 d2 -- d3 )

d3 是 d1 和 d2 之間的較大者.


8.6.1.1210 DMAX
d-max DOUBLE
	( d1 d2 -- d3 )

d3 is the greater of d1 and d2.


8.6.1.1220 DMIN
d-最小值 DOUBLE
	( d1 d2 -- d3 )

d3 是 d1 和 d2 之間的較小者.


8.6.1.1220 DMIN
d-min DOUBLE
	( d1 d2 -- d3 )

d3 is the lesser of d1 and d2.


8.6.1.1230 DNEGATE
d-負值 DOUBLE
	( d1 -- d2 )

d2 是 d1 的負值.


8.6.1.1230 DNEGATE
d-negate DOUBLE
	( d1 -- d2 )

d2 is the negation of d1.


8.6.1.1820 M*/
m-星號-除號 DOUBLE
	( d1 n1 +n2 -- d2 )

將 d1 乘以 n1, 產生中介的三單元結果 t. 將 t 除以 +n2, 得到雙單元商數 d2. 當 +n2 為 0 或負數, 或是商位於超過一個有號雙精確整數的範圍時, 將會出現模稜兩可的情況.

參閱: A.8.6.1.1820 M*/


8.6.1.1820 M*/
m-star-slash DOUBLE
	( d1 n1 +n2 -- d2 )

Multiply d1 by n1 producing the triple-cell intermediate result t. Divide t by +n2 giving the double-cell quotient d2. An ambiguous condition exists if +n2 is zero or negative, or the quotient lies outside of the range of a double-precision signed integer.

See: A.8.6.1.1820 M*/


8.6.1.1830 M+
m-加號 DOUBLE
	( d1|ud1 n -- d2|ud2 )

將 n 加進 d1|ud1, 得到結果 d2|ud2.

參閱: A.8.6.1.1830 M+


8.6.1.1830 M+
m-plus DOUBLE
	( d1|ud1 n -- d2|ud2 )

Add n to d1|ud1, giving the sum d2|ud2.

See: A.8.6.1.1830 M+


8.6.2 雙數值延伸詞(Double-Number extension words)


8.6.2.0420 2ROT
雙-旋轉 DOUBLE EXT
	( x1 x2 x3 x4 x5 x6 -- x3 x4 x5 x6 x1 x2 )

旋轉堆疊上面的三個單元對, 將單元對 x1 x2 變成在堆疊的最上方.


8.6.2.0420 2ROT
two-rote DOUBLE EXT
	( x1 x2 x3 x4 x5 x6 -- x3 x4 x5 x6 x1 x2 )

Rotate the top three cell pairs on the stack bringing cell pair x1 x2 to the top of the stack.


8.6.2.1270 DU<
d-u-小於 DOUBLE EXT
	( ud1 ud2 -- flag )

如果 ud1 小於 ud2 時, flag 為真.


8.6.2.1270 DU<
d-u-less DOUBLE EXT
	( ud1 ud2 -- flag )

flag is true if and only if ud1 is less than ud2.


內容列表(Table of Contents)
下一章(Next Section)