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
9fce0ba9
Kaydet (Commit)
9fce0ba9
authored
Eki 05, 2008
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue 3288: document as_integer_ratio(), fromhex(), and hex().
üst
d12dcaea
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
1 deletion
+33
-1
floatingpoint.rst
Doc/tutorial/floatingpoint.rst
+33
-1
No files found.
Doc/tutorial/floatingpoint.rst
Dosyayı görüntüle @
9fce0ba9
...
...
@@ -138,7 +138,39 @@ method's format specifiers in :ref:`formatstrings`.
If you are a heavy user of floating point operations you should take a look
at the Numerical Python package and many other packages for mathematical and
statistical operations supplied by the SciPy project. See <http://scipy.org>.
Python provides tools that may help on those rare occasions when you really
*do* want to know the exact value of a float. The
:meth:`float.as_integer_ratio` method expresses the value of a float as a
fraction::
>>> x = 3.14159
>>> x.as_integer_ratio()
(3537115888337719L, 1125899906842624L)
Since the ratio is exact, it can be used to losslessly recreate the
original value::
>>> x == 3537115888337719 / 1125899906842624
True
The :meth:`float.hex` method expresses a float in hexadecimal (base
16), again giving the exact value stored by your computer::
>>> x.hex()
'0x1.921f9f01b866ep+1'
This precise hexadecimal representation can be used to reconstruct
the float value exactly::
>>> x == float.fromhex('0x1.921f9f01b866ep+1')
True
Since the representation is exact, it is useful for reliably porting values
across different versions of Python (platform independence) and exchanging
data with other languages that support the same format (such as Java and C99).
.. _tut-fp-error:
Representation Error
...
...
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