manpagez: man pages & more
info coreutils
Home | html | info | man

File: coreutils.info,  Node: Floating point,  Next: Standards conformance,  Prev: Exit status,  Up: Common options

2.12 Floating point numbers
===========================

Commands that accept or produce floating point numbers employ the
floating point representation of the underlying system, and suffer from
rounding error, overflow, and similar floating-point issues.  Almost all
modern systems use IEEE-754 floating point, and it is typically portable
to assume IEEE-754 behavior these days.  IEEE-754 has positive and
negative infinity, distinguishes positive from negative zero, and uses
special values called NaNs to represent invalid computations such as
dividing zero by itself.  For more information, please see David
Goldberg’s paper What Every Computer Scientist Should Know About
Floating-Point Arithmetic
(https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html).

   Commands that accept floating point numbers as options, operands or
input use the standard C functions ‘strtod’ and ‘strtold’ to convert
from text to floating point numbers.  These floating point numbers
therefore can use scientific notation like ‘1.0e-34’ and ‘-10e100’.
Commands that parse floating point also understand case-insensitive
‘inf’, ‘infinity’, and ‘NaN’, although whether such values are useful
depends on the command in question.  Modern C implementations also
accept hexadecimal floating point numbers such as ‘-0x.ep-3’, which
stands for −14/16 times 2^-3, which equals −0.109375.  *Note
(libc)Parsing of Floats::.

   Normally the ‘LC_NUMERIC’ locale determines the decimal-point
character.  However, some commands’ descriptions specify that they
accept numbers in either the current or the C locale; for example, they
treat ‘3.14’ like ‘3,14’ if the current locale uses comma as a decimal
point.

© manpagez.com 2000-2025
Individual documents may contain additional copyright information.