|
14 | 14 | // FIXME: MIN_VALUE and MAX_VALUE literals are parsed as -inf and inf #14353 |
15 | 15 | #![allow(overflowing_literals)] |
16 | 16 |
|
| 17 | +#![stable] |
| 18 | + |
17 | 19 | use intrinsics; |
18 | 20 | use mem; |
19 | 21 | use num::{Float, FPNormal, FPCategory, FPZero, FPSubnormal, FPInfinite, FPNaN}; |
20 | 22 | use num::from_str_radix; |
21 | 23 | use option::Option; |
22 | 24 |
|
| 25 | +#[stable] |
23 | 26 | pub const RADIX: uint = 2u; |
24 | 27 |
|
| 28 | +#[stable] |
25 | 29 | pub const MANTISSA_DIGITS: uint = 24u; |
| 30 | +#[stable] |
26 | 31 | pub const DIGITS: uint = 6u; |
27 | 32 |
|
| 33 | +#[stable] |
28 | 34 | pub const EPSILON: f32 = 1.19209290e-07_f32; |
29 | 35 |
|
30 | 36 | /// Smallest finite f32 value |
| 37 | +#[stable] |
31 | 38 | pub const MIN_VALUE: f32 = -3.40282347e+38_f32; |
32 | 39 | /// Smallest positive, normalized f32 value |
| 40 | +#[stable] |
33 | 41 | pub const MIN_POS_VALUE: f32 = 1.17549435e-38_f32; |
34 | 42 | /// Largest finite f32 value |
| 43 | +#[stable] |
35 | 44 | pub const MAX_VALUE: f32 = 3.40282347e+38_f32; |
36 | 45 |
|
| 46 | +#[stable] |
37 | 47 | pub const MIN_EXP: int = -125; |
| 48 | +#[stable] |
38 | 49 | pub const MAX_EXP: int = 128; |
39 | 50 |
|
| 51 | +#[stable] |
40 | 52 | pub const MIN_10_EXP: int = -37; |
| 53 | +#[stable] |
41 | 54 | pub const MAX_10_EXP: int = 38; |
42 | 55 |
|
| 56 | +#[stable] |
43 | 57 | pub const NAN: f32 = 0.0_f32/0.0_f32; |
| 58 | +#[stable] |
44 | 59 | pub const INFINITY: f32 = 1.0_f32/0.0_f32; |
| 60 | +#[stable] |
45 | 61 | pub const NEG_INFINITY: f32 = -1.0_f32/0.0_f32; |
46 | 62 |
|
47 | 63 | /// Various useful constants. |
| 64 | +#[unstable = "naming scheme needs to be revisited"] |
48 | 65 | pub mod consts { |
49 | 66 | // FIXME: replace with mathematical constants from cmath. |
50 | 67 |
|
51 | | - // FIXME(#5527): These constants should be deprecated once associated |
52 | | - // constants are implemented in favour of referencing the respective members |
53 | | - // of `Float`. |
54 | | - |
55 | 68 | /// Archimedes' constant |
56 | 69 | pub const PI: f32 = 3.14159265358979323846264338327950288_f32; |
57 | 70 |
|
@@ -104,6 +117,7 @@ pub mod consts { |
104 | 117 | pub const LN_10: f32 = 2.30258509299404568401799145468436421_f32; |
105 | 118 | } |
106 | 119 |
|
| 120 | +#[unstable = "trait is unstable"] |
107 | 121 | impl Float for f32 { |
108 | 122 | #[inline] |
109 | 123 | fn nan() -> f32 { NAN } |
@@ -415,12 +429,12 @@ impl Float for f32 { |
415 | 429 |
|
416 | 430 | /// Converts to degrees, assuming the number is in radians. |
417 | 431 | #[inline] |
418 | | - fn to_degrees(self) -> f32 { self * (180.0f32 / Float::pi()) } |
| 432 | + fn to_degrees(self) -> f32 { self * (180.0f32 / consts::PI) } |
419 | 433 |
|
420 | 434 | /// Converts to radians, assuming the number is in degrees. |
421 | 435 | #[inline] |
422 | 436 | fn to_radians(self) -> f32 { |
423 | | - let value: f32 = Float::pi(); |
| 437 | + let value: f32 = consts::PI; |
424 | 438 | self * (value / 180.0f32) |
425 | 439 | } |
426 | 440 | } |
|
0 commit comments