summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorAdrien Hopkins <adrien.p.hopkins@gmail.com>2024-03-23 16:02:51 -0500
committerAdrien Hopkins <adrien.p.hopkins@gmail.com>2024-03-23 16:03:45 -0500
commitcc45a65c78c578eb404d8773b22e5b046917621f (patch)
tree6f53d7c974d930731ad41e80b53407c3458f35d9 /docs
parente1a96524ad9000689e081a6bf52792a886c07222 (diff)
Add fractions using | to expressions
| is like /, but with higher precedence. This feature is a part of GNU Units, and was included in 7Units for compatibility.
Diffstat (limited to 'docs')
-rw-r--r--docs/data_spec.org2
-rw-r--r--docs/data_spec.pdfbin89903 -> 90256 bytes
-rw-r--r--docs/data_spec.tex18
-rw-r--r--docs/manual.org1
-rw-r--r--docs/manual.pdfbin184134 -> 185191 bytes
-rw-r--r--docs/manual.tex37
-rw-r--r--docs/roadmap.org1
7 files changed, 30 insertions, 29 deletions
diff --git a/docs/data_spec.org b/docs/data_spec.org
index 6cf8712..54780e3 100644
--- a/docs/data_spec.org
+++ b/docs/data_spec.org
@@ -23,7 +23,7 @@ This allows unit and prefix files to be easily organized and divided.
** Unit Expressions
The definition part of a unit's line is a unit expression - the same sort of expression you would use in the complex unit converter.
-Expressions should be a standard mathematical expression, which can operate on either numbers or units. The following operators are supported: addition (+), subtraction (-), multiplication (~*~ or no operator), division (~/~), exponentation (~^~; exponent must be a number). Brackets (~(~ and ~)~) may be used to change order of operations, but otherwise standard BEDMAS order is followed (exponentation first, then multiplication and division, then addition and subtraction), with one exception: if a number is multiplied by a unit using spaces, the multiplication will have precedence over division. For example, "2 m / 1 m" is equal to the dimensionless value 2, not 2 m^2. An example of a line defining a unit is:
+Expressions should be a standard mathematical expression, which can operate on either numbers or units. The following operators are supported: addition (+), subtraction (-), multiplication (~*~ or no operator), division (~/~ or ~|~), exponentation (~^~; exponent must be a number). Brackets (~(~ and ~)~) may be used to change order of operations, but otherwise standard BEDMAS order is followed (exponentation first, then multiplication and division, then addition and subtraction), with two exceptions: if a number is multiplied by a unit using spaces, the multiplication will have precedence over division, and division with ~|~ has higher precedence than any other operator. For example, "2 m / 1 m" is equal to the dimensionless value 2, not 2 m^2. An example of a line defining a unit is:
#+BEGIN_SRC
yard 9 dm + 1.4 cm + 4 mm^2 / 10 mm
#+END_SRC
diff --git a/docs/data_spec.pdf b/docs/data_spec.pdf
index 5b3752d..b192e51 100644
--- a/docs/data_spec.pdf
+++ b/docs/data_spec.pdf
Binary files differ
diff --git a/docs/data_spec.tex b/docs/data_spec.tex
index 9bcbe14..82494c9 100644
--- a/docs/data_spec.tex
+++ b/docs/data_spec.tex
@@ -1,4 +1,4 @@
-% Created 2024-03-03 Sun 10:48
+% Created 2024-03-23 Sat 16:01
% Intended LaTeX compiler: pdflatex
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
@@ -30,7 +30,7 @@
\newpage
\section{Unit and Prefix Files}
-\label{sec:org2a50c60}
+\label{sec:org12eca56}
Unit and prefix files specify the units and prefixes that are available to 7Units. Their format is intended to be compatible with 7Units's inspiration, \href{https://www.gnu.org/software/units/}{GNU Units}.
Each unit or prefix is specified by a line in the following format:
@@ -40,7 +40,7 @@ Each unit or prefix is specified by a line in the following format:
The name may not contain whitespace, but the definition can and often will. Lines can be separated by either a line feed (0x0A) or a carriage return followed by a line feed (0x0D 0x0A).
\subsection{Ignored Lines \& Comments}
-\label{sec:orgf5f4195}
+\label{sec:org2f8286a}
All of the following should be ignored:
\begin{itemize}
\item Any line containing only whitespace
@@ -50,25 +50,25 @@ All of the following should be ignored:
This allows unit and prefix files to be easily organized and divided.
\subsection{Unit Expressions}
-\label{sec:org7ab7828}
+\label{sec:orga5cb10a}
The definition part of a unit's line is a unit expression - the same sort of expression you would use in the complex unit converter.
-Expressions should be a standard mathematical expression, which can operate on either numbers or units. The following operators are supported: addition (+), subtraction (-), multiplication (\texttt{*} or no operator), division (\texttt{/}), exponentation (\texttt{\textasciicircum{}}; exponent must be a number). Brackets (\texttt{(} and \texttt{)}) may be used to change order of operations, but otherwise standard BEDMAS order is followed (exponentation first, then multiplication and division, then addition and subtraction), with one exception: if a number is multiplied by a unit using spaces, the multiplication will have precedence over division. For example, "2 m / 1 m" is equal to the dimensionless value 2, not 2 m\textsuperscript{2}. An example of a line defining a unit is:
+Expressions should be a standard mathematical expression, which can operate on either numbers or units. The following operators are supported: addition (+), subtraction (-), multiplication (\texttt{*} or no operator), division (\texttt{/} or \texttt{|}), exponentation (\texttt{\textasciicircum{}}; exponent must be a number). Brackets (\texttt{(} and \texttt{)}) may be used to change order of operations, but otherwise standard BEDMAS order is followed (exponentation first, then multiplication and division, then addition and subtraction), with two exceptions: if a number is multiplied by a unit using spaces, the multiplication will have precedence over division, and division with \texttt{|} has higher precedence than any other operator. For example, "2 m / 1 m" is equal to the dimensionless value 2, not 2 m\textsuperscript{2}. An example of a line defining a unit is:
\begin{verbatim}
yard 9 dm + 1.4 cm + 4 mm^2 / 10 mm
\end{verbatim}
If the definition is an exclamation mark (\texttt{!}), this defines a base unit, which is expected to already be stored in the system.
\subsection{Prefixes \& Prefix Expressions}
-\label{sec:orgf36901d}
+\label{sec:orgac34dfb}
If a line's name part ends in the ASCII dash (\texttt{-}, 0x2D), it defines a prefix instead of a unit (this dash is not included in the prefix's name). Prefix expressions are like unit expressions, but the operands are prefixes and numbers, not units and numbers. Because prefixes do not have a dimension, there are no base prefixes - the exclamation mark is forbidden in prefix expressions.
\section{Dimension Files}
-\label{sec:org42d746d}
+\label{sec:orgb96440f}
Dimension files give names to unit dimensions, so they can be selected in the unit converter to determine which units are shown. Dimension files are similar to unit and prefix files, except that they use a different set of base \emph{dimensions} (defined with ! as usual), and that addition and subtraction are not supported in dimension expressions.
\section{Metric Exception Files}
-\label{sec:org2390d67}
+\label{sec:org727336c}
Metric exception files list exceptions to the One-Way Conversion rule. Units included in these files are always shown on both sides of the unit converter, even if One Way Conversion is enabled. They are just a list of units, one per line. Ignored lines and comments work the same way as in other data files.
\section{Configuration Files}
-\label{sec:orgef3d7a7}
+\label{sec:orge440794}
A configuration file contains one line for each configuration setting, in the format \texttt{key=value}. Check the user manual for the list of configurable setting keys. Ignored lines and comments work the same way as in other data files.
\end{document}
diff --git a/docs/manual.org b/docs/manual.org
index 7e343aa..5b36ba7 100644
--- a/docs/manual.org
+++ b/docs/manual.org
@@ -94,6 +94,7 @@ You can also use the special setting names ~custom_unit_file~, ~custom_dimension
A unit expression is simply a math expression where the values being operated on are units or numbers. The operations that can be used are (in order of precedence):
- Exponentiation (^); the exponent must be an integer. Both units and numbers can be raised to an exponent
- Multiplication (*) and division (/). Multiplication can also be done with a space (so "15 meter" is the same thing as "15 * meter").
+ You can also divide with ~|~ to create fractions. Using ~|~ instead of ~/~ gives the division a higher precedence than any other operator. For example, "2|5^2" evaluates to 4/25, not 2/25.
- Addition (+) and subtraction (-). They can only be done between units of the same dimension (measuring the same thing). So you can add metres, inches and feet together, and you can add joules and calories together, but you can't add metres to seconds, or feet to calories, or watts to pounds.
Brackets can be used to manipulate the order of operations, and nonlinear units like Celsius and Fahrenheit cannot be used in expressions. You can use a value in a nonlinear unit by putting brackets after it - for example, degC(12) represents the value 12 \deg C
diff --git a/docs/manual.pdf b/docs/manual.pdf
index 66b65b1..22ce98d 100644
--- a/docs/manual.pdf
+++ b/docs/manual.pdf
Binary files differ
diff --git a/docs/manual.tex b/docs/manual.tex
index 3ed9b35..d5ca426 100644
--- a/docs/manual.tex
+++ b/docs/manual.tex
@@ -1,4 +1,4 @@
-% Created 2023-09-16 Sat 16:05
+% Created 2024-03-23 Sat 16:00
% Intended LaTeX compiler: pdflatex
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
@@ -21,7 +21,7 @@
pdftitle={7Units User Manual},
pdfkeywords={},
pdfsubject={},
- pdfcreator={Emacs 28.1 (Org mode 9.6.7)},
+ pdfcreator={Emacs 29.2 (Org mode 9.6.15)},
pdflang={English}}
\begin{document}
@@ -30,10 +30,10 @@
\newpage
\section{Introduction and Purpose}
-\label{sec:orgc38fb26}
+\label{sec:org0dbe72d}
7Units is a program that can be used to convert units. This document outlines how to use the program.
\section{System Requirements}
-\label{sec:org0d264f4}
+\label{sec:org2bf9298}
\begin{itemize}
\item Works on all major operating systems \\[0pt]
\textbf{NOTE:} All screenshots in this document were taken on Windows 10. If you use a different operating system, the program will probably look different than what is shown.
@@ -42,9 +42,9 @@
\newpage
\section{How to Use 7Units}
-\label{sec:orgdf5e3e6}
+\label{sec:orgf02f7d8}
\subsection{Simple Unit Conversion}
-\label{sec:orga203874}
+\label{sec:org527dcdb}
\begin{enumerate}
\item Select the "Convert Units" tab if it is not already selected. You should see a screen like in figure \ref{main-interface-dimension}:
\begin{figure}[htbp]
@@ -69,7 +69,7 @@
\end{figure}
\end{enumerate}
\subsection{Complex Unit Conversion}
-\label{sec:org488accc}
+\label{sec:org99aaa43}
\begin{enumerate}
\item Select the "Convert Unit Expressions" if it is not already selected. You should see a screen like in figure \ref{main-interface-expression}:
\begin{figure}[htbp]
@@ -77,7 +77,7 @@
\includegraphics[height=250px]{../screenshots/main-interface-expression-converter.png}
\caption{\label{main-interface-expression}Taken in version 0.3.0}
\end{figure}
-\item Enter a \hyperref[sec:org0d36b62]{unit expression} in the From box. This can be something like "\texttt{7 km}" or "\texttt{6 ft - 2 in}" or "\texttt{3 kg m + 9 lb ft + (35 mm)\textasciicircum{}2 * (85 oz) / (20 in)}".
+\item Enter a \hyperref[sec:orgc3e5dc3]{unit expression} in the From box. This can be something like "\texttt{7 km}" or "\texttt{6 ft - 2 in}" or "\texttt{3 kg m + 9 lb ft + (35 mm)\textasciicircum{}2 * (85 oz) / (20 in)}".
\item Enter a unit name (or another unit expression) in the To box.
\item Press the Convert button. This will calculate the value of the first expression, and convert it to a multiple of the second unit (or expression).
\begin{figure}[htbp]
@@ -87,7 +87,7 @@
\end{figure}
\end{enumerate}
\section{7Units Settings}
-\label{sec:org24852a4}
+\label{sec:org73b708e}
All settings can be accessed in the tab with the gear icon.
\begin{figure}[htbp]
\centering
@@ -95,7 +95,7 @@ All settings can be accessed in the tab with the gear icon.
\caption{The settings menu, as of version 0.4.0}
\end{figure}
\subsection{Rounding Settings}
-\label{sec:org49cb400}
+\label{sec:orgbf8cfcd}
These settings control how the output of a unit conversion is rounded.
\begin{description}
\item[{Fixed Precision}] Round to a fixed number of \href{https://en.wikipedia.org/wiki/Significant\_figures}{significant digits}. The number of significant digits is controlled by the precision slider below.
@@ -103,7 +103,7 @@ These settings control how the output of a unit conversion is rounded.
\item[{Scientific Precision}] Intelligent rounding which uses the precision of the input value(s) to determine the output precision. Not affected by the precision slider.
\end{description}
\subsection{Prefix Repetition Settings}
-\label{sec:orgdad3f6a}
+\label{sec:org7936321}
These settings control when you are allowed to repeat unit prefixes (e.g. kilokilometre)
\begin{description}
\item[{No Repetition}] Units may only have one prefix.
@@ -118,7 +118,7 @@ These settings control when you are allowed to repeat unit prefixes (e.g. kiloki
\end{itemize}
\end{description}
\subsection{Search Settings}
-\label{sec:orge892f5f}
+\label{sec:orgc26929c}
These settings control which prefixes are shown in the "Convert Units" tab. Only coherent SI units (e.g. metre, second, newton, joule) will get prefixes. Some prefixed units are created in the unitfile, and will stay regardless of this setting (though they can be removed from the unitfile).
\begin{description}
\item[{Never Include Prefixed Units}] Prefixed units will only be shown if they are explicitly added to the unitfile.
@@ -126,13 +126,13 @@ These settings control which prefixes are shown in the "Convert Units" tab. Onl
\item[{Include All Single Prefixes}] Every coherent unit will have every prefixed version of it included in the list.
\end{description}
\subsection{Miscellaneous Settings}
-\label{sec:orgf983011}
+\label{sec:orgf44fa1a}
\begin{description}
\item[{Convert One Way Only}] In the simple conversion tab, only imperial/customary units will be shown on the left, and only metric units\footnote{7Units's definition of "metric" is stricter than the SI, but all of the common units that are commonly considered metric but not included in 7Units's definition are included in the exceptions file.} will be shown on the right. Units listed in the exceptions file (\texttt{src/main/resources/metric\_exceptions.txt}) will be shown on both sides. This is a way to reduce the number of options you must search through if you only convert one way. The expressions tab is unaffected.
\item[{Show Duplicates in "Convert Units"}] If unchecked, any unit that has multiple names will only have one included in the Convert Units lists. The selected name will be the longest; if there are multiple longest names one is selected arbitrarily. You will still be able to use these alternate names in the expressions tab.
\end{description}
\subsection{Configuration File}
-\label{sec:orgf29eb6d}
+\label{sec:org9810db1}
The settings are saved in a configuration file. On Windows, this is located at \\[0pt]
\texttt{\%USERPROFILE\%/AppData/Local/SevenUnits/config.txt}. On other operating systems, this is located at \texttt{\$HOME/.config/SevenUnits/config.txt}. The directory containing the \texttt{SevenUnits} directory can be overridden with the environment variables \texttt{\$LOCALAPPDATA} on Windows or \texttt{\$XDG\_CONFIG\_HOME} elsewhere.
@@ -151,18 +151,19 @@ or \texttt{ALL\_METRIC\_PREFIXES}.
You can also use the special setting names \texttt{custom\_unit\_file}, \texttt{custom\_dimension\_file} and \texttt{custom\_exception\_file} to add custom units, dimensions and metric exceptions to the system. These files use the same format as the standard files. These setting names can be used more than once to include multiple unit, dimension or exception files.
\section{Appendices}
-\label{sec:org613821e}
+\label{sec:orgaed9ee0}
\subsection{Unit Expressions}
-\label{sec:org0d36b62}
+\label{sec:orgc3e5dc3}
A unit expression is simply a math expression where the values being operated on are units or numbers. The operations that can be used are (in order of precedence):
\begin{itemize}
\item Exponentiation (\^{}); the exponent must be an integer. Both units and numbers can be raised to an exponent
\item Multiplication (*) and division (/). Multiplication can also be done with a space (so "15 meter" is the same thing as "15 * meter").
+You can also divide with \texttt{|} to create fractions. Using \texttt{|} instead of \texttt{/} gives the division a higher precedence than any other operator. For example, "2|5\textsuperscript{2}" evaluates to 4/25, not 2/25.
\item Addition (+) and subtraction (-). They can only be done between units of the same dimension (measuring the same thing). So you can add metres, inches and feet together, and you can add joules and calories together, but you can't add metres to seconds, or feet to calories, or watts to pounds.
\end{itemize}
Brackets can be used to manipulate the order of operations, and nonlinear units like Celsius and Fahrenheit cannot be used in expressions. You can use a value in a nonlinear unit by putting brackets after it - for example, degC(12) represents the value 12 \textdegree{} C
\subsection{Other Expressions}
-\label{sec:org036b96f}
+\label{sec:org03a3659}
There are also a simplified version of expressions for prefixes and dimensions. Only multiplication, division and exponentation are supported. Currently, exponentation is not supported for dimensions, but that may be fixed in the future.
-\end{document} \ No newline at end of file
+\end{document}
diff --git a/docs/roadmap.org b/docs/roadmap.org
index 2eed941..5a3888f 100644
--- a/docs/roadmap.org
+++ b/docs/roadmap.org
@@ -9,7 +9,6 @@ Feature Requirements:
- 7Units's expression converter should support most or all of the conversion features supported by GNU Units:
- Converting to sums of units (it should also be possible to do this in the unit converter with preset combinations)
- Non-integer exponents
- - Fractions in unit expressions (like ~1|6~)
- (/Optional/) Inverse nonlinear conversion with the tilde prefix
- (/Optional/) Nonlinear units should be specifiable in unit files.
- /Any other feature not listed should be considered optional./