add constants in std::f16::consts
This commit is contained in:
parent
96f6b0be57
commit
5ea4873fbe
@ -15,7 +15,112 @@
|
|||||||
|
|
||||||
/// Basic mathematical constants.
|
/// Basic mathematical constants.
|
||||||
#[unstable(feature = "f16", issue = "116909")]
|
#[unstable(feature = "f16", issue = "116909")]
|
||||||
pub mod consts {}
|
pub mod consts {
|
||||||
|
// FIXME: replace with mathematical constants from cmath.
|
||||||
|
|
||||||
|
/// Archimedes' constant (π)
|
||||||
|
#[unstable(feature = "f16", issue = "116909")]
|
||||||
|
pub const PI: f16 = 3.14159265358979323846264338327950288_f16;
|
||||||
|
|
||||||
|
/// The full circle constant (τ)
|
||||||
|
///
|
||||||
|
/// Equal to 2π.
|
||||||
|
#[unstable(feature = "f16", issue = "116909")]
|
||||||
|
pub const TAU: f16 = 6.28318530717958647692528676655900577_f16;
|
||||||
|
|
||||||
|
/// The golden ratio (φ)
|
||||||
|
#[unstable(feature = "f16", issue = "116909")]
|
||||||
|
// Also, #[unstable(feature = "more_float_constants", issue = "103883")]
|
||||||
|
pub const PHI: f16 = 1.618033988749894848204586834365638118_f16;
|
||||||
|
|
||||||
|
/// The Euler-Mascheroni constant (γ)
|
||||||
|
#[unstable(feature = "f16", issue = "116909")]
|
||||||
|
// Also, #[unstable(feature = "more_float_constants", issue = "103883")]
|
||||||
|
pub const EGAMMA: f16 = 0.577215664901532860606512090082402431_f16;
|
||||||
|
|
||||||
|
/// π/2
|
||||||
|
#[unstable(feature = "f16", issue = "116909")]
|
||||||
|
pub const FRAC_PI_2: f16 = 1.57079632679489661923132169163975144_f16;
|
||||||
|
|
||||||
|
/// π/3
|
||||||
|
#[unstable(feature = "f16", issue = "116909")]
|
||||||
|
pub const FRAC_PI_3: f16 = 1.04719755119659774615421446109316763_f16;
|
||||||
|
|
||||||
|
/// π/4
|
||||||
|
#[unstable(feature = "f16", issue = "116909")]
|
||||||
|
pub const FRAC_PI_4: f16 = 0.785398163397448309615660845819875721_f16;
|
||||||
|
|
||||||
|
/// π/6
|
||||||
|
#[unstable(feature = "f16", issue = "116909")]
|
||||||
|
pub const FRAC_PI_6: f16 = 0.52359877559829887307710723054658381_f16;
|
||||||
|
|
||||||
|
/// π/8
|
||||||
|
#[unstable(feature = "f16", issue = "116909")]
|
||||||
|
pub const FRAC_PI_8: f16 = 0.39269908169872415480783042290993786_f16;
|
||||||
|
|
||||||
|
/// 1/π
|
||||||
|
#[unstable(feature = "f16", issue = "116909")]
|
||||||
|
pub const FRAC_1_PI: f16 = 0.318309886183790671537767526745028724_f16;
|
||||||
|
|
||||||
|
/// 1/sqrt(π)
|
||||||
|
#[unstable(feature = "f16", issue = "116909")]
|
||||||
|
// Also, #[unstable(feature = "more_float_constants", issue = "103883")]
|
||||||
|
pub const FRAC_1_SQRT_PI: f16 = 0.564189583547756286948079451560772586_f16;
|
||||||
|
|
||||||
|
/// 2/π
|
||||||
|
#[unstable(feature = "f16", issue = "116909")]
|
||||||
|
pub const FRAC_2_PI: f16 = 0.636619772367581343075535053490057448_f16;
|
||||||
|
|
||||||
|
/// 2/sqrt(π)
|
||||||
|
#[unstable(feature = "f16", issue = "116909")]
|
||||||
|
pub const FRAC_2_SQRT_PI: f16 = 1.12837916709551257389615890312154517_f16;
|
||||||
|
|
||||||
|
/// sqrt(2)
|
||||||
|
#[unstable(feature = "f16", issue = "116909")]
|
||||||
|
pub const SQRT_2: f16 = 1.41421356237309504880168872420969808_f16;
|
||||||
|
|
||||||
|
/// 1/sqrt(2)
|
||||||
|
#[unstable(feature = "f16", issue = "116909")]
|
||||||
|
pub const FRAC_1_SQRT_2: f16 = 0.707106781186547524400844362104849039_f16;
|
||||||
|
|
||||||
|
/// sqrt(3)
|
||||||
|
#[unstable(feature = "f16", issue = "116909")]
|
||||||
|
// Also, #[unstable(feature = "more_float_constants", issue = "103883")]
|
||||||
|
pub const SQRT_3: f16 = 1.732050807568877293527446341505872367_f16;
|
||||||
|
|
||||||
|
/// 1/sqrt(3)
|
||||||
|
#[unstable(feature = "f16", issue = "116909")]
|
||||||
|
// Also, #[unstable(feature = "more_float_constants", issue = "103883")]
|
||||||
|
pub const FRAC_1_SQRT_3: f16 = 0.577350269189625764509148780501957456_f16;
|
||||||
|
|
||||||
|
/// Euler's number (e)
|
||||||
|
#[unstable(feature = "f16", issue = "116909")]
|
||||||
|
pub const E: f16 = 2.71828182845904523536028747135266250_f16;
|
||||||
|
|
||||||
|
/// log<sub>2</sub>(10)
|
||||||
|
#[unstable(feature = "f16", issue = "116909")]
|
||||||
|
pub const LOG2_10: f16 = 3.32192809488736234787031942948939018_f16;
|
||||||
|
|
||||||
|
/// log<sub>2</sub>(e)
|
||||||
|
#[unstable(feature = "f16", issue = "116909")]
|
||||||
|
pub const LOG2_E: f16 = 1.44269504088896340735992468100189214_f16;
|
||||||
|
|
||||||
|
/// log<sub>10</sub>(2)
|
||||||
|
#[unstable(feature = "f16", issue = "116909")]
|
||||||
|
pub const LOG10_2: f16 = 0.301029995663981195213738894724493027_f16;
|
||||||
|
|
||||||
|
/// log<sub>10</sub>(e)
|
||||||
|
#[unstable(feature = "f16", issue = "116909")]
|
||||||
|
pub const LOG10_E: f16 = 0.434294481903251827651128918916605082_f16;
|
||||||
|
|
||||||
|
/// ln(2)
|
||||||
|
#[unstable(feature = "f16", issue = "116909")]
|
||||||
|
pub const LN_2: f16 = 0.693147180559945309417232121458176568_f16;
|
||||||
|
|
||||||
|
/// ln(10)
|
||||||
|
#[unstable(feature = "f16", issue = "116909")]
|
||||||
|
pub const LN_10: f16 = 2.30258509299404568401799145468436421_f16;
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
impl f16 {
|
impl f16 {
|
||||||
|
Loading…
Reference in New Issue
Block a user