summaryrefslogtreecommitdiff
path: root/doc/textutils.texi
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1996-06-27 02:34:30 +0000
committerJim Meyering <jim@meyering.net>1996-06-27 02:34:30 +0000
commit117fb47f992f0ec4bed6ecb9162b563e654ef5d4 (patch)
tree0ffb15659eb0f5d94d5381aa685041c80c4640ef /doc/textutils.texi
parent1bff89846be155126d4735e8df96f678f6326a06 (diff)
downloadcoreutils-117fb47f992f0ec4bed6ecb9162b563e654ef5d4.tar.xz
Elaborate on how sort -n works.
Diffstat (limited to 'doc/textutils.texi')
-rw-r--r--doc/textutils.texi16
1 files changed, 16 insertions, 0 deletions
diff --git a/doc/textutils.texi b/doc/textutils.texi
index 4f2a291a5..cbe6d7bb7 100644
--- a/doc/textutils.texi
+++ b/doc/textutils.texi
@@ -1796,6 +1796,22 @@ Sort numerically: the number begins each line; specifically, it consists
of optional whitespace, an optional @samp{-} sign, and zero or more
digits, optionally followed by a decimal point and zero or more digits.
+@code{sort -n} uses what might be considered an unconventional method
+to compare strings representing floating point numbers. Rather than
+first converting each string to the C @code{double} type and then
+comparing those values, sort aligns the decimal points in the two
+strings and compares the strings a character at a time. One benefit
+of using this approach is its speed. In practice this is much more
+efficient than performing the two corresponding string-to-double (or even
+string-to-integer) conversions and then comparing doubles. In addition,
+there is no corresponding loss of precision. Converting each string to
+@code{double} before comparison would limit precision to about 16 digits
+on most systems.
+
+Note that neither a leading @samp{+} nor exponential notation is
+recognized. To compare such strings numerically, use the @samp{-g}
+option.
+
@item -r
@opindex -r
@cindex reverse sorting