summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2007-12-01 11:20:10 (GMT)
committerChristian Heimes <christian@cheimes.de>2007-12-01 11:20:10 (GMT)
commitdfdfaab1c54425113e07b623f7dc38f60762cee1 (patch)
tree0ad4a7143ebb830c8879cc7cc686ca67dbe00e13 /Doc
parent9f6d4ceb43583885cd090ff6adb87d31b3ac9c99 (diff)
downloadcpython-dfdfaab1c54425113e07b623f7dc38f60762cee1.zip
cpython-dfdfaab1c54425113e07b623f7dc38f60762cee1.tar.gz
cpython-dfdfaab1c54425113e07b623f7dc38f60762cee1.tar.bz2
Feature #1534
Added PyFloat_GetMax(), PyFloat_GetMin() and PyFloat_GetInfo() to the float API. Added a dictionary sys.float_info with information about the internal floating point type to the sys module.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/c-api/concrete.rst17
-rw-r--r--Doc/library/sys.rst42
2 files changed, 59 insertions, 0 deletions
diff --git a/Doc/c-api/concrete.rst b/Doc/c-api/concrete.rst
index a02332a..aad031b 100644
--- a/Doc/c-api/concrete.rst
+++ b/Doc/c-api/concrete.rst
@@ -557,6 +557,23 @@ Floating Point Objects
without error checking.
+.. cfunction:: PyObject* PyFloat_GetInfo(void)
+
+ Return a :ctype:`PyDictObject` object which contains information about the
+ precision, minimum and maximum values of a float. It's a thin wrapper
+ around the header file :file:`float.h`.
+
+
+.. cfunction:: double PyFloat_GetMax(void)
+
+ Return the maximum representable finite float *DBL_MAX* as C :ctype:`double`.
+
+
+.. cfunction:: double PyFloat_GetMin(void)
+
+ Return the minimum normalized positive float *DBL_MIN* as C :ctype:`double`.
+
+
.. _complexobjects:
Complex Number Objects
diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst
index f254003..d33f532 100644
--- a/Doc/library/sys.rst
+++ b/Doc/library/sys.rst
@@ -240,6 +240,48 @@ always available.
Use :mod:`atexit` instead.
+.. data:: float_info
+
+ A dict holding information about the float type. It contains low level
+ information about the precision and internal representation. Please study
+ your system's :file:`float.h` for more information.
+
+ +---------------------+--------------------------------------------------+
+ | key | explanation |
+ +=====================+==================================================+
+ | :const:`epsilon` | Difference between 1 and the next representable |
+ | | floating point number |
+ +---------------------+--------------------------------------------------+
+ | :const:`dig` | digits (see :file:`float.h`) |
+ +---------------------+--------------------------------------------------+
+ | :const:`mant_dig` | mantissa digits (see :file:`float.h`) |
+ +---------------------+--------------------------------------------------+
+ | :const:`max` | maximum representable finite float |
+ +---------------------+--------------------------------------------------+
+ | :const:`max_exp` | maximum int e such that radix**(e-1) is in the |
+ | | range of finite representable floats |
+ +---------------------+--------------------------------------------------+
+ | :const:`max_10_exp` | maximum int e such that 10**e is in the |
+ | | range of finite representable floats |
+ +---------------------+--------------------------------------------------+
+ | :const:`min` | Minimum positive normalizer float |
+ +---------------------+--------------------------------------------------+
+ | :const:`min_exp` | minimum int e such that radix**(e-1) is a |
+ | | normalized float |
+ +---------------------+--------------------------------------------------+
+ | :const:`min_10_exp` | minimum int e such that 10**e is a normalized |
+ | | float |
+ +---------------------+--------------------------------------------------+
+ | :const:`radix` | radix of exponent |
+ +---------------------+--------------------------------------------------+
+ | :const:`rounds` | addition rounds (see :file:`float.h`) |
+ +---------------------+--------------------------------------------------+
+
+ .. note::
+
+ The information in the table is simplified.
+
+
.. function:: getcheckinterval()
Return the interpreter's "check interval"; see :func:`setcheckinterval`.