% Copyright The Numerical Algorithms Group Limited 1992-94. All rights reserved. % !! DO NOT MODIFY THIS FILE BY HAND !! Created by ht.awk. \newcommand{\DoubleFloatXmpTitle}{DoubleFloat} \newcommand{\DoubleFloatXmpNumber}{9.17} % % ===================================================================== \begin{page}{DoubleFloatXmpPage}{9.17 DoubleFloat} % ===================================================================== \beginscroll % \Language{} provides two kinds of floating point numbers. The domain \spadtype{Float} (abbreviation \spadtype{FLOAT}) implements a model of arbitrary %-% \HDindex{floating point!arbitrary precision}{DoubleFloatXmpPage}{9.17}{DoubleFloat} precision floating point numbers. %-% \HDexptypeindex{Float}{DoubleFloatXmpPage}{9.17}{DoubleFloat} The domain \spadtype{DoubleFloat} (abbreviation \spadtype{DFLOAT}) is intended to make available %-% \HDindex{floating point!hardware}{DoubleFloatXmpPage}{9.17}{DoubleFloat} hardware floating point arithmetic in \Language{}. The actual model of floating point \spadtype{DoubleFloat} that provides is system-dependent. For example, on the IBM system 370 \Language{} uses IBM double precision which has fourteen hexadecimal digits of precision or roughly sixteen decimal digits. Arbitrary precision floats allow the user to specify the precision at which arithmetic operations are computed. Although this is an attractive facility, it comes at a cost. Arbitrary-precision floating-point arithmetic typically takes twenty to two hundred times more time than hardware floating point. The usual arithmetic and elementary functions are available for \spadtype{DoubleFloat}. Use \spadsys{)show DoubleFloat} to get a list of operations or the \HyperName{} \Browse{} facility to get more extensive documentation about \spadtype{DoubleFloat}. \xtc{ By default, floating point numbers that you enter into \Language{} are of type \spadtype{Float}. }{ \spadpaste{2.71828} } You must therefore tell \Language{} that you want to use \spadtype{DoubleFloat} values and operations. The following are some conservative guidelines for getting \Language{} to use \spadtype{DoubleFloat}. \xtc{ To get a value of type \spadtype{DoubleFloat}, use a target with \spadSyntax{@}, \ldots }{ \spadpaste{2.71828@DoubleFloat} } \xtc{ a conversion, \ldots }{ \spadpaste{2.71828 :: DoubleFloat} } \xtc{ or an assignment to a declared variable. It is more efficient if you use a target rather than an explicit or implicit conversion. }{ \spadpaste{eApprox : DoubleFloat := 2.71828 \bound{eApprox}} } \xtc{ You also need to declare functions that work with \spadtype{DoubleFloat}. }{ \spadpaste{avg : List DoubleFloat -> DoubleFloat \bound{avgDec}} } \xtc{ }{ \begin{spadsrc}[\bound{avg}\free{avgDec}] avg l == empty? l => 0 :: DoubleFloat reduce(_+,l) / #l \end{spadsrc} } \xtc{ }{ \spadpaste{avg [] \free{avg}} } \xtc{ }{ \spadpaste{avg [3.4,9.7,-6.8] \free{avg}} } \xtc{ Use package-calling for operations from \spadtype{DoubleFloat} unless the arguments themselves are already of type \spadtype{DoubleFloat}. }{ \spadpaste{cos(3.1415926)\$DoubleFloat} } \xtc{ }{ \spadpaste{cos(3.1415926 :: DoubleFloat)} } By far, the most common usage of \spadtype{DoubleFloat} is for functions to be graphed. For more information about \Language{}'s numerical and graphical facilities, see \downlink{``\ugGraphTitle''}{ugGraphPage} in Section \ugGraphNumber\ignore{ugGraph}, \downlink{``\ugProblemNumericTitle''}{ugProblemNumericPage} in Section \ugProblemNumericNumber\ignore{ugProblemNumeric}, and \downlink{`Float'}{FloatXmpPage}\ignore{Float}. \endscroll \autobuttons \end{page} %