Make tpa the default file format for Teapot
There turned out to be one blocking technical issue for full adpotion of tpa format, and that was the fact that the printed representation of floating values inside the tpa file might not reproduce the same double when read. This change therefore introduces the "hexact" floating point format, based on the the %La format string, which produces a hex representation with exact round trips. While working on this, it was convenient to add a new representation "compact" which is basically the shorter of decimal and scientific representations, without trailing zeros. This is now the default float format, but of course one can select decimal or scientific formats to restore prior appearance. However, full-precision compact format is now the (only) format for editing cell contents, as it is accurate and efficient. Of course you can enter floating point values in any format you like when typing in a formula. The addition of several new floating point options overloaded the menus in terminal teapot, so this change also revamps those menus slightly, including eliminating the unused MenuChoice struct, and just specifying menus with an array of strings. Closes #63.
This commit is contained in:
parent
364ef2c0ea
commit
96079b210e
22 changed files with 923 additions and 841 deletions
176
doc/teapot.lyx
176
doc/teapot.lyx
|
@ -1948,7 +1948,7 @@ status open
|
|||
|
||||
\begin_layout Plain Layout
|
||||
\begin_inset Tabular
|
||||
<lyxtabular version="3" rows="26" columns="3">
|
||||
<lyxtabular version="3" rows="25" columns="3">
|
||||
<features tabularvalignment="middle">
|
||||
<column alignment="left" valignment="top" width="5cm">
|
||||
<column alignment="left" valignment="top">
|
||||
|
@ -2562,35 +2562,6 @@ Set column width
|
|||
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
|
||||
\begin_inset Text
|
||||
|
||||
\begin_layout Plain Layout
|
||||
{Meta-S}
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
</cell>
|
||||
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
|
||||
\begin_inset Text
|
||||
|
||||
\begin_layout Plain Layout
|
||||
Set cell/block scientific notation
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
</cell>
|
||||
</row>
|
||||
<row>
|
||||
<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
|
||||
\begin_inset Text
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
</cell>
|
||||
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
|
||||
\begin_inset Text
|
||||
|
||||
\begin_layout Plain Layout
|
||||
{Meta-E}
|
||||
\end_layout
|
||||
|
@ -3359,9 +3330,43 @@ The precision for the output of floating point values.
|
|||
\end_layout
|
||||
|
||||
\begin_layout Itemize
|
||||
Whether floating point numbers should be printed in scientific notation
|
||||
(0.123e1) or as decimal number (1.23).
|
||||
It only affects the output, if the cell value is a floating point number.
|
||||
The format for floating point numbers when they are printed.
|
||||
This can be
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
decimal
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
(12.34),
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
scientific
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
(1.234e1),
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
compact
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
(a mix of these to produce a compact notation depending on thethe magnitude
|
||||
of the value; this is the default), or
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
hexact
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
(a specialized hexadecimal format used for exact round trips to ASCII format,
|
||||
rarely used for dispaly.) It only affects the output if the cell value is
|
||||
a floating point number.
|
||||
|
||||
\end_layout
|
||||
|
||||
|
@ -4034,7 +4039,25 @@ File Formats
|
|||
\end_layout
|
||||
|
||||
\begin_layout Paragraph
|
||||
XDR (.tp)
|
||||
ASCII (.tpa)
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
The ASCII file format allows easy generation/modification of saved sheets
|
||||
by shell scripts.
|
||||
Note that when reading a .tpa file, either ordinary decimal or scientific
|
||||
formats for floating point number are recognized, as well as the exact
|
||||
hex floating point format used by default when saving.
|
||||
The default extension is
|
||||
\family typewriter
|
||||
.
|
||||
\family default
|
||||
tpa.
|
||||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Paragraph
|
||||
Legacy XDR (.tp)
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
|
@ -4043,28 +4066,31 @@ XDR (eXternal Data Representation) is a standard invented by Sun Microsystems
|
|||
media.
|
||||
Its advantage is that it is widely available and that it defines a portable
|
||||
floating point number format.
|
||||
The native teapot file format uses XDR so it is portable across different
|
||||
machine architectures and operating systems.
|
||||
The advantage of this over the portable ASCII format is that due to the
|
||||
The native teapot file format formerly used XDR so it is portable across
|
||||
different machine architectures and operating systems.
|
||||
The advantage of this over the portable ASCII format was that due to the
|
||||
(usually) missing conversion calculations any floating point constants
|
||||
will be saved/loaded exactly without conversion errors.
|
||||
\end_layout
|
||||
It was discontinued because the ASCII format was made exact by virtue of
|
||||
the exact hexadecimal
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
\begin_layout Paragraph
|
||||
ASCII (.tpa)
|
||||
\end_layout
|
||||
%a
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
\begin_layout Standard
|
||||
The ASCII file format allows easy generation/modification of saved sheets
|
||||
by shell scripts.
|
||||
Due to binary/ASCII conversion, there may be conversion errors in floating
|
||||
point constants.
|
||||
The default extension is
|
||||
\family typewriter
|
||||
.
|
||||
\family default
|
||||
tpa.
|
||||
|
||||
style (
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
hexact
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
) of representing floating point values, and so there was no need for a
|
||||
specialized binary format.
|
||||
Old .tp files may be read, but teapot no longer writes files in this format.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Paragraph
|
||||
|
@ -6254,6 +6280,11 @@ condition
|
|||
expression to avoid recalculation becoming stuck in an infinite loop, however.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
compact used as a keyword to the string() function; listed here to record
|
||||
that this identifier may not be used as a cell label.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
|
||||
\series medium
|
||||
|
@ -6344,7 +6375,7 @@ deg2rad
|
|||
|
||||
x
|
||||
\emph default
|
||||
)
|
||||
)
|
||||
\series default
|
||||
evaluates to the degrees that are equivalent to
|
||||
\emph on
|
||||
|
@ -6495,6 +6526,11 @@ x
|
|||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
hexact used as a keyword to the string() function; listed here to record
|
||||
that this identifier may not be used as a cell label.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
|
||||
\series medium
|
||||
|
@ -7458,20 +7494,24 @@ precision
|
|||
\begin_inset space ~
|
||||
\end_inset
|
||||
|
||||
integer
|
||||
|
||||
\emph on
|
||||
|
||||
\begin_inset space ~
|
||||
\end_inset
|
||||
|
||||
scientific
|
||||
format
|
||||
\emph default
|
||||
]])
|
||||
\series default
|
||||
evaluates to the string representation of its first argument.
|
||||
The optional second argument gives the precision used for converting floating
|
||||
point numbers to string form.
|
||||
The optional third argument may either be the keyword
|
||||
The optional third argument may be one of the keywords
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
decimal
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
,
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
|
@ -7479,16 +7519,24 @@ scientific
|
|||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
or
|
||||
,
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
decimal,
|
||||
compact
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
controlling the type of notation used for converting floating point numbers
|
||||
to string form.
|
||||
, or
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
hexact
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
, controlling the format for converting floating point numbers to string
|
||||
form.
|
||||
If the optional arguments are not specified, current defaults are used.
|
||||
|
||||
\end_layout
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue