coreutils: Floating point
1
1 2.4 Floating point numbers
1 ==========================
1
1 Commands that accept or produce floating point numbers employ the
1 floating point representation of the underlying system, and suffer from
1 rounding error, overflow, and similar floating-point issues. Almost all
1 modern systems use IEEE-754 floating point, and it is typically portable
1 to assume IEEE-754 behavior these days. IEEE-754 has positive and
1 negative infinity, distinguishes positive from negative zero, and uses
1 special values called NaNs to represent invalid computations such as
1 dividing zero by itself. For more information, please see David
1 Goldberg’s paper What Every Computer Scientist Should Know About
1 Floating-Point Arithmetic (http://www.validlab.com/goldberg/paper.pdf).
1
1 Commands that accept floating point numbers as options, operands or
1 input use the standard C functions ‘strtod’ and ‘strtold’ to convert
1 from text to floating point numbers. These floating point numbers
1 therefore can use scientific notation like ‘1.0e-34’ and ‘-10e100’.
1 Commands that parse floating point also understand case-insensitive
1 ‘inf’, ‘infinity’, and ‘NaN’, although whether such values are useful
1 depends on the command in question. Modern C implementations also
1 accept hexadecimal floating point numbers such as ‘-0x.ep-3’, which
1 stands for −14/16 times 2^-3, which equals −0.109375. The ‘LC_NUMERIC’
11 locale determines the decimal-point character. ⇒(libc)Parsing of
Floats.
1