about summary refs log tree commit diff
path: root/src/libstd/num/mod.rs
diff options
context:
space:
mode:
authorAaron Turon <aturon@mozilla.com>2014-04-24 17:09:58 -0700
committerAaron Turon <aturon@mozilla.com>2014-04-24 17:13:33 -0700
commitb8da4d7704fc71c5cb97eb42459bc6d847e96ea6 (patch)
tree6a5ba3ff9b83364ffc59dee834f4b77af4510fda /src/libstd/num/mod.rs
parentb55394415ab63adf32036f63595f3bba3e1c9098 (diff)
downloadrust-b8da4d7704fc71c5cb97eb42459bc6d847e96ea6.tar.gz
rust-b8da4d7704fc71c5cb97eb42459bc6d847e96ea6.zip
add min_pos_value constant for floats
Follow-up on issue #13297 and PR #13710.  Instead of following the (confusing) C/C++ approach
of using `MIN_VALUE` for the smallest *positive* number, we introduce `MIN_POS_VALUE` (and
in the Float trait, `min_pos_value`) to represent this number.

This patch also removes a few remaining redundantly-defined constants that were missed last
time around.
Diffstat (limited to 'src/libstd/num/mod.rs')
-rw-r--r--src/libstd/num/mod.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libstd/num/mod.rs b/src/libstd/num/mod.rs
index dccca82dc79..15269f6b86b 100644
--- a/src/libstd/num/mod.rs
+++ b/src/libstd/num/mod.rs
@@ -190,7 +190,9 @@ pub fn pow<T: One + Mul<T, T>>(mut base: T, mut exp: uint) -> T {
 /// Numbers which have upper and lower bounds
 pub trait Bounded {
     // FIXME (#5527): These should be associated constants
+    /// returns the smallest finite number this type can represent
     fn min_value() -> Self;
+    /// returns the largest finite number this type can represent
     fn max_value() -> Self;
 }
 
@@ -356,6 +358,8 @@ pub trait Float: Signed + Primitive {
     /// Returns the category that this number falls into.
     fn classify(self) -> FPCategory;
 
+    // FIXME (#5527): These should be associated constants
+
     /// Returns the number of binary digits of mantissa that this type supports.
     fn mantissa_digits(unused_self: Option<Self>) -> uint;
     /// Returns the number of base-10 digits of precision that this type supports.
@@ -370,6 +374,8 @@ pub trait Float: Signed + Primitive {
     fn min_10_exp(unused_self: Option<Self>) -> int;
     /// Returns the maximum base-10 exponent that this type can represent.
     fn max_10_exp(unused_self: Option<Self>) -> int;
+    /// Returns the smallest normalized positive number that this type can represent.
+    fn min_pos_value(unused_self: Option<Self>) -> Self;
 
     /// Constructs a floating point number created by multiplying `x` by 2
     /// raised to the power of `exp`.
@@ -434,6 +440,8 @@ pub trait Float: Signed + Primitive {
     /// legs of length `x` and `y`.
     fn hypot(self, other: Self) -> Self;
 
+    // FIXME (#5527): These should be associated constants
+
     /// Archimedes' constant.
     fn pi() -> Self;
     /// 2.0 * pi.