added useful constants to math

This commit is contained in:
Stefan Plantikow 2011-12-22 12:54:38 +01:00
parent 8319b5a252
commit e0cd06053a
3 changed files with 78 additions and 0 deletions

View File

@ -15,6 +15,9 @@ export
frexp, ldexp, ln, ln1p, log10, log2, modf, rint, round, pow, sin,
sinh, sqrt, tan, tanh, trunc, t;
export radix, mantissa_digits, digits, epsilon, min_value, max_value,
min_exp, max_exp, min_10_exp, max_10_exp;
export consts;
type t = f32;
@ -114,6 +117,27 @@ mod consts {
const ln_10: f32 = 2.30258509299404568401799145468436421f32;
}
// These are not defined inside consts:: for consistency with
// the integer types
// PORT check per architecture
const radix: uint = 2u;
const mantissa_digits: uint = 24u;
const digits: uint = 6u;
const epsilon: f32 = 1.19209290e-07f32;
const min_value: f32 = 1.17549435e-38f32;
const max_value: f32 = 3.40282347e+38f32;
const min_exp: int = -125;
const max_exp: int = 128;
const min_10_exp: int = -37;
const max_10_exp: int = 38;
//
// Local Variables:
// mode: rust

View File

@ -15,6 +15,9 @@ export
frexp, ldexp, ln, ln1p, log10, log2, modf, rint, round, pow, sin,
sinh, sqrt, tan, tanh, trunc, t;
export radix, mantissa_digits, digits, epsilon, min_value, max_value,
min_exp, max_exp, min_10_exp, max_10_exp;
export consts;
type t = f64;
@ -114,6 +117,27 @@ mod consts {
const ln_10: f64 = 2.30258509299404568401799145468436421f64;
}
// These are not defined inside consts:: for consistency with
// the integer types
// PORT check per architecture
const radix: uint = 2u;
const mantissa_digits: uint = 53u;
const digits: uint = 15u;
const epsilon: f64 = 2.2204460492503131e-16f64;
const min_value: f64 = 2.2250738585072014e-308f64;
const max_value: f64 = 1.7976931348623157e+308f64;
const min_exp: int = -1021;
const max_exp: int = 1024;
const min_10_exp: int = -307;
const max_10_exp: int = 308;
//
// Local Variables:
// mode: rust

View File

@ -719,6 +719,31 @@ Returns the integral value nearest to but no larger in magnitude than `x`
pure fn trunc(x: float) -> float
{ ret m_float::trunc(x as m_float) as float }
/*
FIXME implement this as soon as const expressions may refer to each other
export radix, mantissa_digits, digits, epsilon, min_value, max_value,
min_exp, max_exp, min_10_exp, max_10_exp;
const radix: m_float = m_float::radix as m_float;
const mantissa_digits: m_float = m_float::mantissa_digits as m_float;
const digits: m_float = m_float::digits as m_float;
const epsilon: m_float = m_float::epsilon as m_float;
const min_value: m_float = m_float::min_value as m_float;
const max_value: m_float = m_float::max_value as m_float;
const min_exp: m_float = m_float::min_exp as m_float;
const max_exp: m_float = m_float::max_exp as m_float;
const min_10_exp: m_float = m_float::min_10_exp as m_float;
const max_10_exp: m_float = m_float::max_10_exp as m_float;
*/
//
// Local Variables:
// mode: rust
@ -728,3 +753,8 @@ pure fn trunc(x: float) -> float
// buffer-file-coding-system: utf-8-unix
// End:
//