Skip to content

Commit

Permalink
libs: stabilize most numerics after RFC changes
Browse files Browse the repository at this point in the history
This commit adds stability markers for the APIs that have recently been
aligned with [numerics
reform](rust-lang/rfcs#369). For APIs that were
changed as part of that reform, `#[unstable]` is used to reflect the
recency, but the APIs will become `#[stable]` in a follow-up pass.

In addition, a few aspects of the APIs not explicitly covered by the RFC
are marked here -- in particular, constants for floats.

This commit does not mark the `uint` or `int` modules as `#[stable]`,
given the ongoing debate out the names and roles of these types.

Due to some deprecation (see the RFC for details), this is a:

[breaking-change]
  • Loading branch information
aturon committed Nov 19, 2014
1 parent e09d986 commit bdbc09a
Show file tree
Hide file tree
Showing 22 changed files with 122 additions and 34 deletions.
22 changes: 18 additions & 4 deletions src/libcore/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,57 @@
// FIXME: MIN_VALUE and MAX_VALUE literals are parsed as -inf and inf #14353
#![allow(overflowing_literals)]

#![stable]

use intrinsics;
use mem;
use num::{Float, FPNormal, FPCategory, FPZero, FPSubnormal, FPInfinite, FPNaN};
use num::from_str_radix;
use option::Option;

#[stable]
pub const RADIX: uint = 2u;

#[stable]
pub const MANTISSA_DIGITS: uint = 24u;
#[stable]
pub const DIGITS: uint = 6u;

#[stable]
pub const EPSILON: f32 = 1.19209290e-07_f32;

/// Smallest finite f32 value
#[stable]
pub const MIN_VALUE: f32 = -3.40282347e+38_f32;
/// Smallest positive, normalized f32 value
#[stable]
pub const MIN_POS_VALUE: f32 = 1.17549435e-38_f32;
/// Largest finite f32 value
#[stable]
pub const MAX_VALUE: f32 = 3.40282347e+38_f32;

#[stable]
pub const MIN_EXP: int = -125;
#[stable]
pub const MAX_EXP: int = 128;

#[stable]
pub const MIN_10_EXP: int = -37;
#[stable]
pub const MAX_10_EXP: int = 38;

#[stable]
pub const NAN: f32 = 0.0_f32/0.0_f32;
#[stable]
pub const INFINITY: f32 = 1.0_f32/0.0_f32;
#[stable]
pub const NEG_INFINITY: f32 = -1.0_f32/0.0_f32;

/// Various useful constants.
#[unstable = "naming scheme needs to be revisited"]
pub mod consts {
// FIXME: replace with mathematical constants from cmath.

// FIXME(#5527): These constants should be deprecated once associated
// constants are implemented in favour of referencing the respective members
// of `Float`.

/// Archimedes' constant
pub const PI: f32 = 3.14159265358979323846264338327950288_f32;

Expand Down Expand Up @@ -104,6 +117,7 @@ pub mod consts {
pub const LN_10: f32 = 2.30258509299404568401799145468436421_f32;
}

#[unstable = "trait is unstable"]
impl Float for f32 {
#[inline]
fn nan() -> f32 { NAN }
Expand Down
20 changes: 18 additions & 2 deletions src/libcore/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// FIXME: MIN_VALUE and MAX_VALUE literals are parsed as -inf and inf #14353
#![allow(overflowing_literals)]

#![stable]

use intrinsics;
use mem;
use num::{Float, FPNormal, FPCategory, FPZero, FPSubnormal, FPInfinite, FPNaN};
Expand All @@ -24,33 +26,46 @@ use option::Option;
// constants are implemented in favour of referencing the respective
// members of `Bounded` and `Float`.

#[stable]
pub const RADIX: uint = 2u;

#[stable]
pub const MANTISSA_DIGITS: uint = 53u;
#[stable]
pub const DIGITS: uint = 15u;

#[stable]
pub const EPSILON: f64 = 2.2204460492503131e-16_f64;

/// Smallest finite f64 value
#[stable]
pub const MIN_VALUE: f64 = -1.7976931348623157e+308_f64;
/// Smallest positive, normalized f64 value
#[stable]
pub const MIN_POS_VALUE: f64 = 2.2250738585072014e-308_f64;
/// Largest finite f64 value
#[stable]
pub const MAX_VALUE: f64 = 1.7976931348623157e+308_f64;

#[stable]
pub const MIN_EXP: int = -1021;
#[stable]
pub const MAX_EXP: int = 1024;

#[stable]
pub const MIN_10_EXP: int = -307;
#[stable]
pub const MAX_10_EXP: int = 308;

#[stable]
pub const NAN: f64 = 0.0_f64/0.0_f64;

#[stable]
pub const INFINITY: f64 = 1.0_f64/0.0_f64;

#[stable]
pub const NEG_INFINITY: f64 = -1.0_f64/0.0_f64;

/// Various useful constants.
#[unstable = "naming scheme needs to be revisited"]
pub mod consts {
// FIXME: replace with mathematical constants from cmath.

Expand Down Expand Up @@ -110,6 +125,7 @@ pub mod consts {
pub const LN_10: f64 = 2.30258509299404568401799145468436421_f64;
}

#[unstable = "trait is unstable"]
impl Float for f64 {
#[inline]
fn nan() -> f64 { NAN }
Expand Down
3 changes: 1 addition & 2 deletions src/libcore/num/i16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

//! Operations and constants for signed 16-bits integers (`i16` type)
#![unstable]
#![stable]
#![doc(primitive = "i16")]

int_module!(i16, 16)

3 changes: 1 addition & 2 deletions src/libcore/num/i32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

//! Operations and constants for signed 32-bits integers (`i32` type)
#![unstable]
#![stable]
#![doc(primitive = "i32")]

int_module!(i32, 32)

3 changes: 1 addition & 2 deletions src/libcore/num/i64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

//! Operations and constants for signed 64-bits integers (`i64` type)
#![unstable]
#![stable]
#![doc(primitive = "i64")]

int_module!(i64, 64)

3 changes: 1 addition & 2 deletions src/libcore/num/i8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

//! Operations and constants for signed 8-bits integers (`i8` type)
#![unstable]
#![stable]
#![doc(primitive = "i8")]

int_module!(i8, 8)

Loading

0 comments on commit bdbc09a

Please sign in to comment.