Commit ad184565 authored by pknaggs's avatar pknaggs
Browse files

Added x:stoftos (F>S S>F)

Changed F94 for F12
Added word number for DFFIELD: FFIELD: FTRUNC FVALUE SFFIELD:
Changed child stack effect for DFFIELD: FFIELD: SFFIELD:
Corrected typo for F.
Minor alteration to rational for FATAN2, FEXPM1
parent f970d6e9
Loading
Loading
Loading
Loading
+92 −38
Original line number Original line Diff line number Diff line
% !TeX root = forth.tex
% !TeX spell check = en_US

\chapter{The optional Floating-Point word set} % 12
\chapter{The optional Floating-Point word set} % 12
\wordlist{floating}
\wordlist{floating}


@@ -264,6 +267,10 @@ See:
	(\wref{floating:Fd}{F.},
	(\wref{floating:Fd}{F.},
	 \wref{floating:FEd}{FE.},
	 \wref{floating:FEd}{FE.},
	 \wref{floating:FSd}{FS.}).
	 \wref{floating:FSd}{FS.}).
\item \place{x:stoftos}{\param{n} can't be precisely represented as
	\emph{float} in \wref{floating:StoF}{S>F};}
\item \place{x:stoftos}{integer part of \emph{float} can't be represented
	by \param{n} in \wref{floating:FtoS}{F>S}.}
\end{itemize}
\end{itemize}


\subsubsection{Other system documentation} % 12.4.1.3
\subsubsection{Other system documentation} % 12.4.1.3
@@ -297,8 +304,8 @@ See:


\section{Compliance and labeling} % 12.5
\section{Compliance and labeling} % 12.5


\cbstart\patch{F94}
\cbstart\patch{F12}
\subsection[Forth systems]{ANS\strike{3.5}{25} Forth systems} % 12.5.1
\subsection[Forth-\snapshot systems]{Forth-\snapshot\strike{-1}{25} systems} % 12.5.1
\cbend
\cbend


The phrase ``Providing the Floating-Point word set'' shall be
The phrase ``Providing the Floating-Point word set'' shall be
@@ -314,8 +321,8 @@ The phrase ``Providing the Floating-Point Extensions word set'' shall
be appended to the label of any Standard System that provides all of
be appended to the label of any Standard System that provides all of
the Floating-Point and Floating-Point Extensions word sets.
the Floating-Point and Floating-Point Extensions word sets.


\cbstart\patch{F94}
\cbstart\patch{F12}
\subsection[Forth programs]{ANS\strike{3.5}{25} Forth programs} % 12.5.2
\subsection[Forth-\snapshot programs]{Forth-\snapshot\strike{-1}{25} programs} % 12.5.2
\cbend
\cbend


The phrase ``Requiring the Floating-Point word set'' shall be
The phrase ``Requiring the Floating-Point word set'' shall be
@@ -376,7 +383,7 @@ word sets.
		does the text interpreter since the latter defines rules for
		does the text interpreter since the latter defines rules for
		composing source programs whereas \word{toFLOAT} defines rules
		composing source programs whereas \word{toFLOAT} defines rules
		for accepting data. \word{toFLOAT} is defined as broadly as is
		for accepting data. \word{toFLOAT} is defined as broadly as is
		feasible to permit input of data from \remove{F94}{ANS} Forth systems as well
		feasible to permit input of data from Forth\place{F12}{-\snapshot} systems as well
		as other widely used standard programming environments.
		as other widely used standard programming environments.


		This is a synthesis of common FORTRAN practice. Embedded spaces
		This is a synthesis of common FORTRAN practice. Embedded spaces
@@ -385,7 +392,7 @@ word sets.


		While \word{toFLOAT} is not required to treat a string of blanks
		While \word{toFLOAT} is not required to treat a string of blanks
		as zero, this behavior is strongly encouraged, since a future
		as zero, this behavior is strongly encouraged, since a future
		version of \replace{F94}{ANS Forth}{this standard} may include such a requirement.
		version of this standard may include such a requirement.
	\end{rationale}
	\end{rationale}
\end{worddef}
\end{worddef}


@@ -806,7 +813,7 @@ word sets.


% ---------------------------------------------------------
% ---------------------------------------------------------


\begin{worddef}{}{DFFIELD:}[d-f-field-colon][X:structures]
\begin{worddef}{1207}[40]{DFFIELD:}[d-f-field-colon][X:structures]
\item \stack{n_1 "<spaces>name"}{n_2}
\item \stack{n_1 "<spaces>name"}{n_2}


	Skip leading space delimiters. Parse \param{name} delimited by
	Skip leading space delimiters. Parse \param{name} delimited by
@@ -818,18 +825,18 @@ word sets.
	given below.
	given below.


\execute[name]
\execute[name]
\cbstart\patch{ed11}
\cbstart\patch{ed12}
	\stack{a-addr_{\sout{1}}}{\sout{a}\uline{df}-addr_{\sout{2}}}
	\stack{\sout{a-}addr_{\uline{1}}}{\sout{df-}addr_{\uline{2}}}
\cbend
\cbend


	Add the \param{offset} calculated during the compile time action to
	Add the \param{offset} calculated during the compile time action to
\cbstart\param{a-addr_{\sout{1}}}\cbend\ 
\cbstart\param{\sout{a-}addr_{\uline{1}}}\cbend\ 
	giving the double-float aligned address
	giving the double-float aligned address
\cbstart\param{\sout{a}\uline{df}-addr_{\sout{2}}}.\cbend
\cbstart\param{\sout{df-}addr_{\uline{2}}}.\cbend


\see \wref{facility:+FIELD}{+FIELD},
\see \wref{facility:+FIELD}{+FIELD},
	\wref{facility:BEGIN-STRUCTURE}{BEGIN-STRUCTURE},
	\wref{facility:BEGIN-STRUCTURE}{BEGIN-STRUCTURE}, \\
	\wref{facility:END-STRUCTURE}{END-STRUCTURE}, \linebreak
	\wref{facility:END-STRUCTURE}{END-STRUCTURE},
	\rref{facility:FIELD:}{}.
	\rref{facility:FIELD:}{}.
\end{worddef}
\end{worddef}


@@ -862,7 +869,7 @@ word sets.
\end{worddef}
\end{worddef}




\begin{worddef}[Fd]{1427}{F.}[f-dot]
\begin{worddef}[Fd]{1427}{F.{}}[f-dot]
\item \stack{}{} \stack[F]{r}{} or
\item \stack{}{} \stack[F]{r}{} or
	\stack{r}{}
	\stack{r}{}


@@ -879,11 +886,36 @@ word sets.
	\rref{floating:Fd}{}.
	\rref{floating:Fd}{}.


	\begin{rationale} % A.12.6.1.1427 F.
	\begin{rationale} % A.12.6.1.1427 F.
		For example, \texttt{1E3} \word{Fd} displays \texttt{1000.} .
		For example, \texttt{1E3} \replace{ed12}{\textbf{\texttt{F}}}{ \word{Fd}} displays \texttt{1000.} .
	\end{rationale}
	\end{rationale}
\end{worddef}
\end{worddef}




% ========== x:stoftos ==========

\begin{worddef*}[FtoS]{1471}{F>S}[F to S][x:stoftos]
\item \stack{}{n} \stack[F]{r}{} or \stack{r}{n}

	\uline{\param{n} is the single-cell signed-integer equivalent of the
	integer portion of \param{r}.  The fractional portion of
	\param{r} is discarded.  An ambiguous condition exists if
	the integer portion of \param{r} cannot be precisely
	represented as a single-cell signed integer.}

\note \uline{Rounding the floating-point value prior to calling \word{FtoS} is
	advised.}

\see \uline{\wref{floating:StoF}{}.}

	\begin{implement}
		\uline{\word{:} \word{FtoS} \word{p} r -{}- n )} \\
		\tab \uline{\word{FtoD} \word[double]{DtoS}} \\
		\uline{\word{;}}
	\end{implement}
\end{worddef*}

% ==============================

\begin{worddef}{1474}{FABS}[f-abs]
\begin{worddef}{1474}{FABS}[f-abs]
\item \stack[F]{r_1}{r_2} or
\item \stack[F]{r_1}{r_2} or
	\stack{r_1}{r_2}
	\stack{r_1}{r_2}
@@ -981,11 +1013,12 @@ word sets.
		Thus the phrase \word{FSINCOS} \word{F/} is functionally
		Thus the phrase \word{FSINCOS} \word{F/} is functionally
		equivalent to \word{FTAN}, but is useful over only a limited
		equivalent to \word{FTAN}, but is useful over only a limited
		and discontinuous range of angles, whereas \word{FSINCOS} and
		and discontinuous range of angles, whereas \word{FSINCOS} and
		\word{FATAN2} are useful for all angles. This ordering has
		\word{FATAN2} are useful for all angles.
\remove{ed12}{This ordering has
		been found convenient for nearly two decades, and has the
		been found convenient for nearly two decades, and has the
		added benefit of being easy to remember. A corollary to this
		added benefit of being easy to remember. A corollary to this
		observation is that vectors in general should appear on the
		observation is that vectors in general should appear on the
		stack in this order.
		stack in this order.}


		The argument order for \word{FATAN2} is the same, converting a
		The argument order for \word{FATAN2} is the same, converting a
		vector in the conventional representation to a scalar angle.
		vector in the conventional representation to a scalar angle.
@@ -1210,14 +1243,14 @@ word sets.
		This function allows accurate computation when its arguments
		This function allows accurate computation when its arguments
		are close to zero, and provides a useful base for the standard
		are close to zero, and provides a useful base for the standard
		exponential functions. Hyperbolic functions such as
		exponential functions. Hyperbolic functions such as
		\textsf{cosh($x$)} can be efficiently and accurately
\textsf{\replace{ed12}{cosh}{sinh}($x$)} can be efficiently and accurately
		implemented by using \word{FEXPM1}; accuracy is lost in this
		implemented by using \word{FEXPM1}; accuracy is lost in this
		function for small values of $x$ if the word \word{FEXP} is
		function for small values of $x$ if the word \word{FEXP} is
		used.
		used.


		An important application of this word is in finance; say a loan
		An important application of this word is in finance; say a loan
		is repaid at 15\% per year; what is the daily rate? On a computer
		is repaid at 15\% per year; what is the daily rate? On a computer
		with single precision (six decimal digit) accuracy:
		with single\place{ed12}{-}precision (six decimal digit) accuracy:


		\begin{enumerate}
		\begin{enumerate}
		\item[1.] Using \word{FLN} and \word{FEXP}:
		\item[1.] Using \word{FLN} and \word{FEXP}:
@@ -1227,7 +1260,7 @@ word sets.
			form the exponent using \word{FEXP} = 1.00038, and \\
			form the exponent using \word{FEXP} = 1.00038, and \\
			subtract one (1) and convert to percentage = 0.038\%.
			subtract one (1) and convert to percentage = 0.038\%.
		\end{enumerate}
		\end{enumerate}
		Thus we only have two digit accuracy.
		Thus we only have two\place{ed12}{-}digit accuracy.
		\begin{enumerate}
		\begin{enumerate}
		\item[2.] Using \word{FLNP1} and \word{FEXPM1}:
		\item[2.] Using \word{FLNP1} and \word{FEXPM1}:


@@ -1239,9 +1272,9 @@ word sets.
			\word{FEXPM1} = 3.82983E-4, and \\
			\word{FEXPM1} = 3.82983E-4, and \\
			convert to percentage = 0.0382983\%.
			convert to percentage = 0.0382983\%.
		\end{enumerate}
		\end{enumerate}
		This is full six digit accuracy.
		This is full six\place{ed12}{-}digit accuracy.


		The presence of this word allows the hyperbolic functions to
		\replace{ed12}{The presence of this}{ This} \remove{ed12}{word} allows the hyperbolic functions to
		be computed with usable accuracy. For example, the hyperbolic
		be computed with usable accuracy. For example, the hyperbolic
		sine can be defined as:
		sine can be defined as:


@@ -1257,7 +1290,7 @@ word sets.


% ---------------------------------------------------------
% ---------------------------------------------------------


\begin{worddef}{}{FFIELD:}[f-field-colon][X:structures]
\begin{worddef}{1517}{FFIELD:}[f-field-colon][X:structures]
\item \stack{n_1 "<spaces>name"}{n_2}
\item \stack{n_1 "<spaces>name"}{n_2}


	Skip leading space delimiters. Parse \param{name} delimited by
	Skip leading space delimiters. Parse \param{name} delimited by
@@ -1268,18 +1301,18 @@ word sets.
	given below.
	given below.


\execute[name]
\execute[name]
\cbstart\patch{ed11}
\cbstart\patch{ed12}
	\stack{a-addr_{\sout{1}}}{\sout{a}\uline{f}-addr_{\sout{2}}}
	\stack{\sout{a-}addr_{\uline{1}}}{\sout{f-}addr_{\uline{2}}}
\cbend
\cbend


	Add the \param{offset} calculated during the compile time action to
	Add the \param{offset} calculated during the compile time action to
\cbstart\param{a-addr_{\sout{1}}}\cbend\ 
\cbstart\param{\sout{a-}addr_{\uline{1}}}\cbend\ 
	giving the float aligned address
	giving the float aligned address
\cbstart\param{\sout{a}\uline{f}-addr_{\sout{2}}}.\cbend
\cbstart\param{\sout{f-}addr_{\uline{2}}}.\cbend


\see \wref{facility:+FIELD}{+FIELD},
\see \wref{facility:+FIELD}{+FIELD},
	\wref{facility:BEGIN-STRUCTURE}{BEGIN-STRUCTURE},
	\wref{facility:BEGIN-STRUCTURE}{BEGIN-STRUCTURE}, \\
	\wref{facility:END-STRUCTURE}{END-STRUCTURE}, \linebreak
	\wref{facility:END-STRUCTURE}{END-STRUCTURE},
	\rref{facility:FIELD:}{}.
	\rref{facility:FIELD:}{}.
\end{worddef}
\end{worddef}


@@ -1408,7 +1441,7 @@ word sets.


% ---------------------------------------------------------
% ---------------------------------------------------------


\begin{worddef}{}{FTRUNC}[f-trunc][x:ftrunc]
\begin{worddef}{1627}{FTRUNC}[f-trunc][x:ftrunc]
\item \stack[F]{r_1}{r_2} or \stack{r_1}{r_2}
\item \stack[F]{r_1}{r_2} or \stack{r_1}{r_2}


	Round \param{r_1} to an integral value using the ``round
	Round \param{r_1} to an integral value using the ``round
@@ -1446,7 +1479,7 @@ word sets.


% ---------------------------------------------------------
% ---------------------------------------------------------


\begin{worddef}{}{FVALUE}[f-value][X:fvalue]
\begin{worddef}{1628}{FVALUE}[f-value][X:fvalue]
\item \stack[F]{r}{} \stack{"<spaces>name"}{} or
\item \stack[F]{r}{} \stack{"<spaces>name"}{} or
	\stack{r "<spaces>name"}{}
	\stack{r "<spaces>name"}{}


@@ -1543,6 +1576,27 @@ word sets.
\end{worddef}
\end{worddef}




% ========== x:stoftos ==========

\begin{worddef*}[StoF]{2175}{S>F}[S to F][x:stoftos]
\item \stack{n}{} \stack[F]{}{r} or \stack{n}{r}

	\uline{\param{r} is the floating-point equivalent of the single-cell
	value \param{n}.  An ambiguous condition exists if \param{n}
	can not be precisely represented as a floating-point value.}

\see \uline{\wref{floating:FtoS}{F>S}.}

	\begin{implement}
		\uline{\word{:} \word{StoF} \word{p} n -{}- r )} \\
		\tab \uline{\word{StoD} \word{DtoF}} \\
		\uline{\word{;}}
	\end{implement}
\end{worddef*}

% ==============================


\begin{worddef}{2200}{SET-PRECISION}
\begin{worddef}{2200}{SET-PRECISION}
\item \stack{u}{}
\item \stack{u}{}


@@ -1607,7 +1661,7 @@ word sets.


% ---------------------------------------------------------
% ---------------------------------------------------------


\begin{worddef}{}{SFFIELD:}[s-f-field-colon][X:structures]
\begin{worddef}{2206}[40]{SFFIELD:}[s-f-field-colon][X:structures]
\item \stack{n_1 "<spaces>name"}{n_2}
\item \stack{n_1 "<spaces>name"}{n_2}


	Skip leading space delimiters. Parse \param{name} delimited by
	Skip leading space delimiters. Parse \param{name} delimited by
@@ -1619,18 +1673,18 @@ word sets.
	given below.
	given below.


\execute[name]
\execute[name]
\cbstart\patch{ed11}
\cbstart\patch{ed12}
	\stack{a-addr_{\sout{1}}}{\sout{a}\uline{sf}-addr_{\sout{2}}}
	\stack{\sout{a-}addr_{\uline{1}}}{\sout{sf-}addr_{\uline{2}}}
\cbend
\cbend


	Add the \param{offset} calculated during the compile time action to
	Add the \param{offset} calculated during the compile time action to
\cbstart\param{a-addr_{\sout{1}}}\cbend\ 
\cbstart\param{\sout{a-}addr_{\uline{1}}}\cbend\ 
	giving the single-float aligned address
	giving the single-float aligned address
\cbstart\param{\sout{a}\uline{sf}-addr_{\sout{2}}}.\cbend
\cbstart\param{\sout{sf-}addr_{\uline{2}}}.\cbend


\see \wref{facility:+FIELD}{+FIELD},
\see \wref{facility:+FIELD}{+FIELD},
	\wref{facility:BEGIN-STRUCTURE}{BEGIN-STRUCTURE},
	\wref{facility:BEGIN-STRUCTURE}{BEGIN-STRUCTURE}, \\
	\wref{facility:END-STRUCTURE}{END-STRUCTURE}, \linebreak
	\wref{facility:END-STRUCTURE}{END-STRUCTURE},
	\rref{facility:FIELD:}{}.
	\rref{facility:FIELD:}{}.
\end{worddef}
\end{worddef}