;ò ëBc@s]dZdZdZdkZdkZeiddƒddjZeo7eidd ƒdZeidd ƒdZ e Z n4eidd ƒdZeidd ƒdZ e Z d „Z d„Z d„Z d„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zedjo eƒndS(sÃUtilities for handling IEEE 754 floating point special values This python module implements constants and functions for working with IEEE754 double-precision special values. It provides constants for Not-a-Number (NaN), Positive Infinity (PosInf), and Negative Infinity (NegInf), as well as functions to test for these values. The code is implemented in pure python by taking advantage of the 'struct' standard module. Care has been taken to generate proper results on both big-endian and little-endian machines. Some efficiency could be gained by translating the core routines into C. See for reference material on the IEEE 754 floating point standard. Further information on this package is available at . ------------------------------------------------------------------ Author: Gregory R. Warnes Date: 2005-02-24 Version: 0.7.2 Copyright: (c) 2003-2005 Pfizer, Licensed to PSF under a Contributor Agreement License: Licensed under the Apache License, Version 2.0 (the"License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ------------------------------------------------------------------ s0.7.2s7$Id: fpconst.py,v 1.16 2005/02/24 17:42:03 warnes Exp $NsiiissdsøsðsøÿsðcCsBttidtid|ƒƒƒ}t o|iƒn|SdS(sEUse struct.unpack to decode a double precision float into eight bytess8BsdN(slistsstructsunpackspacksdvalstmps _big_endiansreverse(sdvalstmp((s@/mnt/gmirror/ports/math/py-fpconst/work/fpconst-0.7.2/fpconst.pys_double_as_bytes9s $cCs t|ƒ}|dd?d@SdS(sAExtract the sign bit from a double-precision floating point valueiiiN(s_double_as_bytessdvalsbb(sdvalsbb((s@/mnt/gmirror/ports/math/py-fpconst/work/fpconst-0.7.2/fpconst.pys_signDs cCs,t|ƒ}|dd>|dd?Bd@SdS(sExtract the exponentent bits from a double-precision floating point value. Note that for normalized values, the exponent bits have an offset of 1023. As a consequence, the actual exponentent is obtained by subtracting 1023 from the value returned by this function iiiiÿN(s_double_as_bytessdvalsbb(sdvalsbb((s@/mnt/gmirror/ports/math/py-fpconst/work/fpconst-0.7.2/fpconst.pys _exponentIs cCsXt|ƒ}|ddd>@}||dd>7}||dd>7}||d7}|Sd S( sLExtract the _mantissa bits from a double-precision floating point value.iii0ii(ii iN(s_double_as_bytessdvalsbbsmantissa(sdvalsmantissasbb((s@/mnt/gmirror/ports/math/py-fpconst/work/fpconst-0.7.2/fpconst.pys _mantissaTs cCs6t|ƒ}|dd@tti|dƒBdjSdS(sIDetermine whether the mantissa bits of the given double are all zero.iiiiN(s_double_as_bytessdvalsbbsreducesoperatorsor_(sdvalsbb((s@/mnt/gmirror/ports/math/py-fpconst/work/fpconst-0.7.2/fpconst.pys_zero_mantissa_s cCs"t|ƒdjo t|ƒ SdS(sADetermine if the argument is a IEEE 754 NaN (Not a Number) value.iÿN(s _exponentsvalues_zero_mantissa(svalue((s@/mnt/gmirror/ports/math/py-fpconst/work/fpconst-0.7.2/fpconst.pysisNaNiscCs!t|ƒdjo t|ƒSdS(s\Determine if the argument is an infinite IEEE 754 value (positive or negative inifinity)iÿN(s _exponentsvalues_zero_mantissa(svalue((s@/mnt/gmirror/ports/math/py-fpconst/work/fpconst-0.7.2/fpconst.pysisInfmscCst|ƒdjSdS(slDetermine if the argument is an finite IEEE 754 value (i.e., is not NaN, positive or negative inifinity)iÿN(s _exponentsvalue(svalue((s@/mnt/gmirror/ports/math/py-fpconst/work/fpconst-0.7.2/fpconst.pysisFiniterscCs4t|ƒdjot|ƒdjo t|ƒSdS(s?Determine if the argument is a IEEE 754 positive infinity valueiiÿN(s_signsvalues _exponents_zero_mantissa(svalue((s@/mnt/gmirror/ports/math/py-fpconst/work/fpconst-0.7.2/fpconst.pysisPosInfwscCs4t|ƒdjot|ƒdjo t|ƒSdS(s?Determine if the argument is a IEEE 754 negative infinity valueiiÿN(s_signsvalues _exponents_zero_mantissa(svalue((s@/mnt/gmirror/ports/math/py-fpconst/work/fpconst-0.7.2/fpconst.pysisNegInf|scCslttƒ pt‚ttƒ pt‚ttƒpt‚tdƒ pt‚tdƒ pt‚dS(Nf1.0f-1.0(sisNaNsPosInfsAssertionErrorsNegInfsNaN(((s@/mnt/gmirror/ports/math/py-fpconst/work/fpconst-0.7.2/fpconst.pys test_isNaN…s cCskttƒpt‚ttƒpt‚ttƒ pt‚tdƒ pt‚tdƒ pt‚dS(Nf1.0f-1.0(sisInfsPosInfsAssertionErrorsNegInfsNaN(((s@/mnt/gmirror/ports/math/py-fpconst/work/fpconst-0.7.2/fpconst.pys test_isInfŒs cCskttƒ pt‚ttƒ pt‚ttƒ pt‚tdƒpt‚tdƒpt‚dS(Nf1.0f-1.0(sisFinitesPosInfsAssertionErrorsNegInfsNaN(((s@/mnt/gmirror/ports/math/py-fpconst/work/fpconst-0.7.2/fpconst.pys test_isFinite“s cCslttƒpt‚ttƒ pt‚ttƒ pt‚tdƒ pt‚tdƒ pt‚dS(Nf1.0f-1.0(sisPosInfsPosInfsAssertionErrorsNegInfsNaN(((s@/mnt/gmirror/ports/math/py-fpconst/work/fpconst-0.7.2/fpconst.pys test_isPosInfšs cCslttƒ pt‚ttƒpt‚ttƒ pt‚tdƒ pt‚tdƒ pt‚dS(Nf1.0f-1.0(sisNegInfsPosInfsAssertionErrorsNegInfsNaN(((s@/mnt/gmirror/ports/math/py-fpconst/work/fpconst-0.7.2/fpconst.pys test_isNegInf¡s cCs'tƒtƒtƒtƒtƒdS(N(s test_isNaNs test_isInfs test_isFinites test_isPosInfs test_isNegInf(((s@/mnt/gmirror/ports/math/py-fpconst/work/fpconst-0.7.2/fpconst.pystest©s s__main__(s__doc__s __version__sidentsstructsoperatorspacks _big_endiansunpacksNaNsPosInfsNegInfs_double_as_bytess_signs _exponents _mantissas_zero_mantissasisNaNsisInfsisFinitesisPosInfsisNegInfs test_isNaNs test_isInfs test_isFinites test_isPosInfs test_isNegInfstests__name__(s test_isNaNsisPosInfs test_isFinitesoperators test_isNegInfsNegInfsisNaNs _exponents _big_endiansstructsNaNsisInfs _mantissas_double_as_bytesstests __version__s_signs test_isPosInfsPosInfsisNegInfsisFinites_zero_mantissasidents test_isInf((s@/mnt/gmirror/ports/math/py-fpconst/work/fpconst-0.7.2/fpconst.pys?%s: