Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-121905: Consistently use "floating-point" instead of "floating point" #121907

Merged
merged 8 commits into from
Jul 19, 2024
8 changes: 4 additions & 4 deletions Doc/c-api/arg.rst
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,10 @@ Numbers
length 1, to a C :c:expr:`int`.

``f`` (:class:`float`) [float]
Convert a Python floating point number to a C :c:expr:`float`.
Convert a Python floating-point number to a C :c:expr:`float`.

``d`` (:class:`float`) [double]
Convert a Python floating point number to a C :c:expr:`double`.
Convert a Python floating-point number to a C :c:expr:`double`.

``D`` (:class:`complex`) [Py_complex]
Convert a Python complex number to a C :c:type:`Py_complex` structure.
Expand Down Expand Up @@ -642,10 +642,10 @@ Building values
object of length 1.
``d`` (:class:`float`) [double]
Convert a C :c:expr:`double` to a Python floating point number.
Convert a C :c:expr:`double` to a Python floating-point number.
``f`` (:class:`float`) [float]
Convert a C :c:expr:`float` to a Python floating point number.
Convert a C :c:expr:`float` to a Python floating-point number.
``D`` (:class:`complex`) [Py_complex \*]
Convert a C :c:type:`Py_complex` structure to a Python complex number.
Expand Down
10 changes: 5 additions & 5 deletions Doc/c-api/float.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

.. _floatobjects:

Floating Point Objects
Floating-Point Objects
======================

.. index:: pair: object; floating point
.. index:: pair: object; floating-point
AA-Turner marked this conversation as resolved.
Show resolved Hide resolved


.. c:type:: PyFloatObject

This subtype of :c:type:`PyObject` represents a Python floating point object.
This subtype of :c:type:`PyObject` represents a Python floating-point object.


.. c:var:: PyTypeObject PyFloat_Type

This instance of :c:type:`PyTypeObject` represents the Python floating point
This instance of :c:type:`PyTypeObject` represents the Python floating-point
type. This is the same object as :class:`float` in the Python layer.


Expand Down Expand Up @@ -45,7 +45,7 @@ Floating Point Objects
.. c:function:: double PyFloat_AsDouble(PyObject *pyfloat)

Return a C :c:expr:`double` representation of the contents of *pyfloat*. If
*pyfloat* is not a Python floating point object but has a :meth:`~object.__float__`
*pyfloat* is not a Python floating-point object but has a :meth:`~object.__float__`
method, this method will first be called to convert *pyfloat* into a float.
If :meth:`!__float__` is not defined then it falls back to :meth:`~object.__index__`.
This method returns ``-1.0`` upon failure, so one should call
Expand Down
2 changes: 1 addition & 1 deletion Doc/c-api/marshal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Numeric values are stored with the least significant byte first.

The module supports two versions of the data format: version 0 is the
historical version, version 1 shares interned strings in the file, and upon
unmarshalling. Version 2 uses a binary format for floating point numbers.
unmarshalling. Version 2 uses a binary format for floating-point numbers.
``Py_MARSHAL_VERSION`` indicates the current file format (currently 2).


Expand Down
8 changes: 4 additions & 4 deletions Doc/c-api/number.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ Number Protocol
Return a reasonable approximation for the mathematical value of *o1* divided by
*o2*, or ``NULL`` on failure. The return value is "approximate" because binary
floating point numbers are approximate; it is not possible to represent all real
numbers in base two. This function can return a floating point value when
floating-point numbers are approximate; it is not possible to represent all real
numbers in base two. This function can return a floating-point value when
passed two integers. This is the equivalent of the Python expression ``o1 / o2``.
Expand Down Expand Up @@ -177,8 +177,8 @@ Number Protocol
Return a reasonable approximation for the mathematical value of *o1* divided by
*o2*, or ``NULL`` on failure. The return value is "approximate" because binary
floating point numbers are approximate; it is not possible to represent all real
numbers in base two. This function can return a floating point value when
floating-point numbers are approximate; it is not possible to represent all real
numbers in base two. This function can return a floating-point value when
passed two integers. The operation is done *in-place* when *o1* supports it.
This is the equivalent of the Python statement ``o1 /= o2``.
Expand Down
4 changes: 2 additions & 2 deletions Doc/faq/design.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ operations. This means that as far as floating-point operations are concerned,
Python behaves like many popular languages including C and Java.

Many numbers that can be written easily in decimal notation cannot be expressed
exactly in binary floating-point. For example, after::
exactly in binary floating point. For example, after::

>>> x = 1.2

Expand All @@ -87,7 +87,7 @@ which is exactly::
The typical precision of 53 bits provides Python floats with 15--16
decimal digits of accuracy.

For a fuller explanation, please see the :ref:`floating point arithmetic
For a fuller explanation, please see the :ref:`floating-point arithmetic
<tut-fp-issues>` chapter in the Python tutorial.


Expand Down
4 changes: 2 additions & 2 deletions Doc/faq/library.rst
Original file line number Diff line number Diff line change
Expand Up @@ -718,12 +718,12 @@ is simple::
import random
random.random()

This returns a random floating point number in the range [0, 1).
This returns a random floating-point number in the range [0, 1).

There are also many other specialized generators in this module, such as:

* ``randrange(a, b)`` chooses an integer in the range [a, b).
* ``uniform(a, b)`` chooses a floating point number in the range [a, b).
* ``uniform(a, b)`` chooses a floating-point number in the range [a, b).
* ``normalvariate(mean, sdev)`` samples the normal (Gaussian) distribution.

Some higher-level functions operate on sequences directly, such as:
Expand Down
2 changes: 1 addition & 1 deletion Doc/faq/programming.rst
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ How do I convert a string to a number?
--------------------------------------

For integers, use the built-in :func:`int` type constructor, e.g. ``int('144')
== 144``. Similarly, :func:`float` converts to floating-point,
== 144``. Similarly, :func:`float` converts to a floating-point number,
e.g. ``float('144') == 144.0``.

By default, these interpret the number as decimal, so that ``int('0144') ==
Expand Down
4 changes: 2 additions & 2 deletions Doc/library/array.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
--------------

This module defines an object type which can compactly represent an array of
basic values: characters, integers, floating point numbers. Arrays are sequence
basic values: characters, integers, floating-point numbers. Arrays are sequence
types and behave very much like lists, except that the type of objects stored in
them is constrained. The type is specified at object creation time by using a
:dfn:`type code`, which is a single character. The following type codes are
Expand Down Expand Up @@ -263,7 +263,7 @@ The string representation is guaranteed to be able to be converted back to an
array with the same type and value using :func:`eval`, so long as the
:class:`~array.array` class has been imported using ``from array import array``.
Variables ``inf`` and ``nan`` must also be defined if it contains
corresponding floating point values.
corresponding floating-point values.
Examples::

array('l')
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/colorsys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The :mod:`colorsys` module defines bidirectional conversions of color values
between colors expressed in the RGB (Red Green Blue) color space used in
computer monitors and three other coordinate systems: YIQ, HLS (Hue Lightness
Saturation) and HSV (Hue Saturation Value). Coordinates in all of these color
spaces are floating point values. In the YIQ space, the Y coordinate is between
spaces are floating-point values. In the YIQ space, the Y coordinate is between
0 and 1, but the I and Q coordinates can be positive or negative. In all other
spaces, the coordinates are all between 0 and 1.

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/configparser.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,7 @@ ConfigParser Objects
.. method:: getfloat(section, option, *, raw=False, vars=None[, fallback])

A convenience method which coerces the *option* in the specified *section*
to a floating point number. See :meth:`get` for explanation of *raw*,
to a floating-point number. See :meth:`get` for explanation of *raw*,
*vars* and *fallback*.


Expand Down
22 changes: 11 additions & 11 deletions Doc/library/decimal.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
:mod:`!decimal` --- Decimal fixed point and floating point arithmetic
:mod:`!decimal` --- Decimal fixed-point and floating-point arithmetic
=====================================================================

.. module:: decimal
Expand Down Expand Up @@ -31,7 +31,7 @@
--------------

The :mod:`decimal` module provides support for fast correctly rounded
decimal floating point arithmetic. It offers several advantages over the
decimal floating-point arithmetic. It offers several advantages over the
:class:`float` datatype:

* Decimal "is based on a floating-point model which was designed with people
Expand Down Expand Up @@ -207,7 +207,7 @@ a decimal raises :class:`InvalidOperation`::
.. versionchanged:: 3.3

Decimals interact well with much of the rest of Python. Here is a small decimal
floating point flying circus:
floating-point flying circus:

.. doctest::
:options: +NORMALIZE_WHITESPACE
Expand Down Expand Up @@ -373,7 +373,7 @@ Decimal objects
digits, and an integer exponent. For example, ``Decimal((0, (1, 4, 1, 4), -3))``
returns ``Decimal('1.414')``.

If *value* is a :class:`float`, the binary floating point value is losslessly
If *value* is a :class:`float`, the binary floating-point value is losslessly
converted to its exact decimal equivalent. This conversion can often require
53 or more digits of precision. For example, ``Decimal(float('1.1'))``
converts to
Expand Down Expand Up @@ -403,7 +403,7 @@ Decimal objects
Underscores are allowed for grouping, as with integral and floating-point
literals in code.

Decimal floating point objects share many properties with the other built-in
Decimal floating-point objects share many properties with the other built-in
numeric types such as :class:`float` and :class:`int`. All of the usual math
operations and special methods apply. Likewise, decimal objects can be
copied, pickled, printed, used as dictionary keys, used as set elements,
Expand Down Expand Up @@ -445,7 +445,7 @@ Decimal objects
Mixed-type comparisons between :class:`Decimal` instances and other
numeric types are now fully supported.

In addition to the standard numeric properties, decimal floating point
In addition to the standard numeric properties, decimal floating-point
objects also have a number of specialized methods:


Expand Down Expand Up @@ -1741,7 +1741,7 @@ The following table summarizes the hierarchy of signals::

.. _decimal-notes:

Floating Point Notes
Floating-Point Notes
--------------------


Expand All @@ -1754,7 +1754,7 @@ can still incur round-off error when non-zero digits exceed the fixed precision.

The effects of round-off error can be amplified by the addition or subtraction
of nearly offsetting quantities resulting in loss of significance. Knuth
provides two instructive examples where rounded floating point arithmetic with
provides two instructive examples where rounded floating-point arithmetic with
insufficient precision causes the breakdown of the associative and distributive
properties of addition:

Expand Down Expand Up @@ -1844,7 +1844,7 @@ treated as equal and their sign is informational.
In addition to the two signed zeros which are distinct yet equal, there are
various representations of zero with differing precisions yet equivalent in
value. This takes a bit of getting used to. For an eye accustomed to
normalized floating point representations, it is not immediately obvious that
normalized floating-point representations, it is not immediately obvious that
the following calculation returns a value equal to zero:

>>> 1 / Decimal('Infinity')
Expand Down Expand Up @@ -2171,7 +2171,7 @@ value unchanged:

Q. Is there a way to convert a regular float to a :class:`Decimal`?

A. Yes, any binary floating point number can be exactly expressed as a
A. Yes, any binary floating-point number can be exactly expressed as a
Decimal though an exact conversion may take more precision than intuition would
suggest:

Expand Down Expand Up @@ -2225,7 +2225,7 @@ Q. Is the CPython implementation fast for large numbers?
A. Yes. In the CPython and PyPy3 implementations, the C/CFFI versions of
the decimal module integrate the high speed `libmpdec
<https://www.bytereef.org/mpdecimal/doc/libmpdec/index.html>`_ library for
arbitrary precision correctly rounded decimal floating point arithmetic [#]_.
arbitrary precision correctly rounded decimal floating-point arithmetic [#]_.
``libmpdec`` uses `Karatsuba multiplication
<https://en.wikipedia.org/wiki/Karatsuba_algorithm>`_
for medium-sized numbers and the `Number Theoretic Transform
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/email.utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ of the new API.

Fri, 09 Nov 2001 01:08:47 -0000

Optional *timeval* if given is a floating point time value as accepted by
Optional *timeval* if given is a floating-point time value as accepted by
:func:`time.gmtime` and :func:`time.localtime`, otherwise the current time is
used.

Expand Down
4 changes: 2 additions & 2 deletions Doc/library/exceptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,8 @@ The following exceptions are the exceptions that are usually raised.
represented. This cannot occur for integers (which would rather raise
:exc:`MemoryError` than give up). However, for historical reasons,
OverflowError is sometimes raised for integers that are outside a required
range. Because of the lack of standardization of floating point exception
handling in C, most floating point operations are not checked.
range. Because of the lack of standardization of floating-point exception
handling in C, most floating-point operations are not checked.


.. exception:: PythonFinalizationError
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/fractions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ another rational number, or from a string.
:class:`Fraction` instance with the same value. The next two versions accept
either a :class:`float` or a :class:`decimal.Decimal` instance, and return a
:class:`Fraction` instance with exactly the same value. Note that due to the
usual issues with binary floating-point (see :ref:`tut-fp-issues`), the
usual issues with binary floating point (see :ref:`tut-fp-issues`), the
argument to ``Fraction(1.1)`` is not exactly equal to 11/10, and so
``Fraction(1.1)`` does *not* return ``Fraction(11, 10)`` as one might expect.
(But see the documentation for the :meth:`limit_denominator` method below.)
Expand Down
14 changes: 7 additions & 7 deletions Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ are always available. They are listed here in alphabetical order.
.. function:: abs(x)

Return the absolute value of a number. The argument may be an
integer, a floating point number, or an object implementing
integer, a floating-point number, or an object implementing
:meth:`~object.__abs__`.
If the argument is a complex number, its magnitude is returned.

Expand Down Expand Up @@ -544,7 +544,7 @@ are always available. They are listed here in alphabetical order.
Take two (non-complex) numbers as arguments and return a pair of numbers
consisting of their quotient and remainder when using integer division. With
mixed operand types, the rules for binary arithmetic operators apply. For
integers, the result is the same as ``(a // b, a % b)``. For floating point
integers, the result is the same as ``(a // b, a % b)``. For floating-point
numbers the result is ``(q, a % b)``, where *q* is usually ``math.floor(a /
b)`` but may be 1 less than that. In any case ``q * b + a % b`` is very
close to *a*, if ``a % b`` is non-zero it has the same sign as *b*, and ``0
Expand Down Expand Up @@ -740,7 +740,7 @@ are always available. They are listed here in alphabetical order.
single: NaN
single: Infinity

Return a floating point number constructed from a number or a string.
Return a floating-point number constructed from a number or a string.

Examples:

Expand Down Expand Up @@ -781,8 +781,8 @@ are always available. They are listed here in alphabetical order.
Case is not significant, so, for example, "inf", "Inf", "INFINITY", and
"iNfINity" are all acceptable spellings for positive infinity.

Otherwise, if the argument is an integer or a floating point number, a
floating point number with the same value (within Python's floating point
Otherwise, if the argument is an integer or a floating-point number, a
floating-point number with the same value (within Python's floating-point
precision) is returned. If the argument is outside the range of a Python
float, an :exc:`OverflowError` will be raised.

Expand Down Expand Up @@ -1010,7 +1010,7 @@ are always available. They are listed here in alphabetical order.
If the argument defines :meth:`~object.__int__`,
``int(x)`` returns ``x.__int__()``. If the argument defines
:meth:`~object.__index__`, it returns ``x.__index__()``.
For floating point numbers, this truncates towards zero.
For floating-point numbers, this truncates towards zero.

If the argument is not a number or if *base* is given, then it must be a string,
:class:`bytes`, or :class:`bytearray` instance representing an integer
Expand Down Expand Up @@ -1928,7 +1928,7 @@ are always available. They are listed here in alphabetical order.

For some use cases, there are good alternatives to :func:`sum`.
The preferred, fast way to concatenate a sequence of strings is by calling
``''.join(sequence)``. To add floating point values with extended precision,
``''.join(sequence)``. To add floating-point values with extended precision,
see :func:`math.fsum`\. To concatenate a series of iterables, consider using
:func:`itertools.chain`.

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/itertools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ loops that truncate the stream.
yield n
n += step

When counting with floating point numbers, better accuracy can sometimes be
When counting with floating-point numbers, better accuracy can sometimes be
achieved by substituting multiplicative code such as: ``(start + step * i
for i in count())``.

Expand Down
4 changes: 2 additions & 2 deletions Doc/library/locale.rst
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ The :mod:`locale` module defines the following exception and functions:
.. function:: format_string(format, val, grouping=False, monetary=False)

Formats a number *val* according to the current :const:`LC_NUMERIC` setting.
The format follows the conventions of the ``%`` operator. For floating point
The format follows the conventions of the ``%`` operator. For floating-point
values, the decimal point is modified if appropriate. If *grouping* is ``True``,
also takes the grouping into account.

Expand Down Expand Up @@ -455,7 +455,7 @@ The :mod:`locale` module defines the following exception and functions:

.. function:: str(float)

Formats a floating point number using the same format as the built-in function
Formats a floating-point number using the same format as the built-in function
``str(float)``, but takes the decimal point into account.


Expand Down
6 changes: 3 additions & 3 deletions Doc/library/marshal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ supports a substantially wider range of objects than marshal.

Not all Python object types are supported; in general, only objects whose value
is independent from a particular invocation of Python can be written and read by
this module. The following types are supported: booleans, integers, floating
point numbers, complex numbers, strings, bytes, bytearrays, tuples, lists, sets,
this module. The following types are supported: booleans, integers, floating-point
numbers, complex numbers, strings, bytes, bytearrays, tuples, lists, sets,
frozensets, dictionaries, and code objects (if *allow_code* is true),
where it should be understood that
tuples, lists, sets, frozensets and dictionaries are only supported as long as
Expand Down Expand Up @@ -142,7 +142,7 @@ In addition, the following constants are defined:

Indicates the format that the module uses. Version 0 is the historical
format, version 1 shares interned strings and version 2 uses a binary format
for floating point numbers.
for floating-point numbers.
Version 3 adds support for object instancing and recursion.
The current version is 4.

Expand Down
Loading
Loading