diff options
| author | Juan Marín Noguera <juan@mnpi.eu> | 2025-05-25 10:39:23 +0200 |
|---|---|---|
| committer | Juan Marín Noguera <juan@mnpi.eu> | 2025-05-25 10:40:27 +0200 |
| commit | 3dd6e4f0044f6ac711506fcd56d6845ad4f23a4a (patch) | |
| tree | 31050c440c8ada29a4cbc2eec568282e1540dd14 /vol2 | |
| parent | 32119b4cc2f104267462261e58831969eec5fcfb (diff) | |
4.2.3 Double-Precision Calculations
Diffstat (limited to 'vol2')
| -rw-r--r-- | vol2/4.2.3.lyx | 245 | ||||
| -rw-r--r-- | vol2/index.lyx | 14 |
2 files changed, 256 insertions, 3 deletions
diff --git a/vol2/4.2.3.lyx b/vol2/4.2.3.lyx new file mode 100644 index 0000000..f25be0a --- /dev/null +++ b/vol2/4.2.3.lyx @@ -0,0 +1,245 @@ +#LyX 2.4 created this file. For more info see https://www.lyx.org/ +\lyxformat 620 +\begin_document +\begin_header +\save_transient_properties true +\origin unavailable +\textclass book +\begin_preamble +\input defs +\end_preamble +\use_default_options true +\maintain_unincluded_children no +\language english +\language_package default +\inputencoding utf8 +\fontencoding auto +\font_roman "default" "default" +\font_sans "default" "default" +\font_typewriter "default" "default" +\font_math "auto" "auto" +\font_default_family default +\use_non_tex_fonts false +\font_sc false +\font_roman_osf false +\font_sans_osf false +\font_typewriter_osf false +\font_sf_scale 100 100 +\font_tt_scale 100 100 +\use_microtype false +\use_dash_ligatures true +\graphics default +\default_output_format default +\output_sync 0 +\bibtex_command default +\index_command default +\float_placement class +\float_alignment class +\paperfontsize default +\spacing single +\use_hyperref false +\papersize default +\use_geometry false +\use_package amsmath 1 +\use_package amssymb 1 +\use_package cancel 1 +\use_package esint 1 +\use_package mathdots 1 +\use_package mathtools 1 +\use_package mhchem 1 +\use_package stackrel 1 +\use_package stmaryrd 1 +\use_package undertilde 1 +\cite_engine basic +\cite_engine_type default +\biblio_style plain +\use_bibtopic false +\use_indices false +\paperorientation portrait +\suppress_date false +\justification true +\use_refstyle 1 +\use_formatted_ref 0 +\use_minted 0 +\use_lineno 0 +\index Index +\shortcut idx +\color #008000 +\end_index +\secnumdepth 3 +\tocdepth 3 +\paragraph_separation indent +\paragraph_indentation default +\is_math_indent 0 +\math_numbering_side default +\quotes_style english +\dynamic_quotes 0 +\papercolumns 1 +\papersides 1 +\paperpagestyle default +\tablestyle default +\tracking_changes false +\output_changes false +\change_bars false +\postpone_fragile_content false +\html_math_output 0 +\html_css_as_file 0 +\html_be_strict false +\docbook_table_output 0 +\docbook_mathml_prefix 1 +\end_header + +\begin_body + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc5[24] +\end_layout + +\end_inset + +How should Program A be changed so that extra accuracy is achieved, + essentially by working with a nine-byte accumulator instead of an eight-byte accumulator to the right of the radix point? + Specify all changes that are required, + and determine the difference in execution time caused by these changes. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Right now the program adds in pieces of 4 bytes to avoid overflow, + but we may as well detect the overflow in the lower half and add it to the higher half if needed. + For this, + the following changes would be needed: +\end_layout + +\begin_layout Enumerate +Add +\family typewriter +JOV OFLO +\family default + after line 6. +\end_layout + +\begin_layout Enumerate +Change line 23 to +\family typewriter +SRAX 0,1 +\family default +, + so then +\family typewriter +ARG:ARGX +\family default + contains +\begin_inset Formula $v_{1}\,v_{2}\,\dots\,v_{9}\,0$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +Change line 31 to +\family typewriter +SLAX 5 +\family default +, + so rA contains the bytes +\begin_inset Formula $u_{6}\,u_{7}\,u_{8}\,0\,0$ +\end_inset + + and the code below adds +\begin_inset Formula $0\,u_{6}\,u_{7}\,u_{8}\,0$ +\end_inset + + plus +\begin_inset Formula $0\,v_{6}\,v_{7}\,v_{8}\,v_{9}$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +Change line 39 to +\family typewriter +ADD ACC +\family default + to get +\begin_inset Formula $u_{1}\,u_{2}\,u_{3}\,u_{4}\,u_{5}$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +Now line 40 adds +\begin_inset Formula $v_{1}\,v_{2}\,v_{3}\,v_{4}\,v_{5}$ +\end_inset + + to +\begin_inset Formula $u_{1}\,u_{2}\,u_{3}\,u_{4}\,u_{5}$ +\end_inset + +, + so overflow can occur, + but overflow or a change of sign cannot because +\begin_inset Formula $|u|\geq|v|$ +\end_inset + +. + To handle this overflow and to shift the argument appropriately, + we add the following after that line: +\begin_inset listings +inline false +status open + +\begin_layout Plain Layout + +SRAX 1 +\end_layout + +\begin_layout Plain Layout + +JNOV *+3 +\end_layout + +\begin_layout Plain Layout + +STA *+1(SIGN) +\end_layout + +\begin_layout Plain Layout + +INCA 1 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +This adds 7u of runtime to the program, + 4u if there's no overflow. + Note that the modified program has not been tested. + Knuth's solution is slightly faster if there's no overflow. +\end_layout + +\end_body +\end_document diff --git a/vol2/index.lyx b/vol2/index.lyx index 22d5987..584a80d 100644 --- a/vol2/index.lyx +++ b/vol2/index.lyx @@ -1064,13 +1064,21 @@ Double-Precision Calculations \end_layout \begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "4.2.3.lyx" +literal "false" + +\end_inset + + \begin_inset Note Note status open \begin_layout Plain Layout -7+0; - 5 (0:28) -> 3d, - -1/3 + +\family typewriter +A10+R25 \end_layout \end_inset |
