| 1 |
import math |
| 2 |
from rpython.rtyper.tool import rffi_platform |
| 3 |
from rpython.translator.tool.cbuild import ExternalCompilationInfo |
| 4 |
|
| 5 |
|
| 6 |
class CConfig: |
| 7 |
_compilation_info_ = ExternalCompilationInfo(includes=['float.h']) |
| 8 |
|
| 9 |
DBL_MAX = rffi_platform.DefinedConstantDouble('DBL_MAX') |
| 10 |
DBL_MIN = rffi_platform.DefinedConstantDouble('DBL_MIN') |
| 11 |
DBL_MANT_DIG = rffi_platform.ConstantInteger('DBL_MANT_DIG') |
| 12 |
|
| 13 |
|
| 14 |
for k, v in rffi_platform.configure(CConfig).items(): |
| 15 |
assert v is not None, "no value found for %r" % k |
| 16 |
globals()[k] = v |
| 17 |
|
| 18 |
|
| 19 |
assert 0.0 < DBL_MAX < (1e200*1e200) |
| 20 |
assert math.isinf(DBL_MAX * 1.0001) |
| 21 |
assert DBL_MIN > 0.0 |
| 22 |
assert DBL_MIN * (2**-53) == 0.0 |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
M_LN2 = 0.6931471805599453094 |
| 27 |
M_LN10 = 2.302585092994045684 |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
CM_LARGE_DOUBLE = DBL_MAX/4. |
| 35 |
CM_SQRT_LARGE_DOUBLE = math.sqrt(CM_LARGE_DOUBLE) |
| 36 |
CM_LOG_LARGE_DOUBLE = math.log(CM_LARGE_DOUBLE) |
| 37 |
CM_SQRT_DBL_MIN = math.sqrt(DBL_MIN) |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
CM_SCALE_UP = (2*(DBL_MANT_DIG/2) + 1) |
| 45 |
CM_SCALE_DOWN = -(CM_SCALE_UP+1)/2 |