Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
47c74ac9
Kaydet (Commit)
47c74ac9
authored
Kas 21, 2010
tarafından
Mark Dickinson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #10488: Bring documentation for 'float' builtin up to date.
üst
faed5b51
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
20 deletions
+48
-20
functions.rst
Doc/library/functions.rst
+48
-20
No files found.
Doc/library/functions.rst
Dosyayı görüntüle @
47c74ac9
...
@@ -399,26 +399,54 @@ are always available. They are listed here in alphabetical order.
...
@@ -399,26 +399,54 @@ are always available. They are listed here in alphabetical order.
.. function:: float([x])
.. function:: float([x])
Convert a string or a number to floating point. If the argument is a string,
.. index::
it must contain a possibly signed decimal or floating point number, possibly
single: NaN
embedded in whitespace. The argument may also be ``'[+|-]nan'`` or
single: Infinity
``'[+|-]inf'``. Otherwise, the argument may be an integer or a floating
point number, and a floating point number with the same value (within
Convert a string or a number to floating point.
Python's floating point precision) is returned. If no argument is given,
``0.0`` is returned.
If the argument is a string, it should contain a decimal number, optionally
preceded by a sign, and optionally embedded in whitespace. The optional
.. note::
sign may be ``'+'`` or ``'-'``; a ``'+'`` sign has no effect on the value
produced. The argument may also be a string representing a NaN
.. index::
(not-a-number), or a positive or negative infinity. More precisely, the
single: NaN
input must conform to the following grammar after leading and trailing
single: Infinity
whitespace characters are removed:
When passing in a string, values for NaN and Infinity may be returned,
.. productionlist::
depending on the underlying C library. Float accepts the strings
sign: "+" | "-"
``'nan'``, ``'inf'`` and ``'-inf'`` for NaN and positive or negative
infinity: "Infinity" | "inf"
infinity. The case and a leading + are ignored as well as a leading - is
nan: "nan"
ignored for NaN. Float always represents NaN and infinity as ``nan``,
numeric-value: `floatnumber` | `infinity` | `nan`
``inf`` or ``-inf``.
numeric-string: [`sign`] `numeric-value`
Here ``floatnumber`` is the form of a Python floating-point literal,
described in :ref:`floating`. 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
precision) is returned. If the argument is outside the range of a Python
float, an :exc:`OverflowError` will be raised.
For a general Python object ``x``, ``float(x)`` delegates to
``x.__float__()``.
If no argument is given, ``0.0`` is returned.
Examples::
>>> float('+1.23')
1.23
>>> float(' -12345\n')
-12345.0
>>> float('1e-003')
0.001
>>> float('+1E6')
1000000.0
>>> float('-Infinity')
-inf
The float type is described in :ref:`typesnumeric`.
The float type is described in :ref:`typesnumeric`.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment