File tree 1 file changed +18
-1
lines changed
1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 1
1
use core:: mem;
2
+ use core:: ops;
2
3
3
4
use super :: int:: Int ;
4
5
@@ -8,10 +9,23 @@ pub mod pow;
8
9
pub mod sub;
9
10
10
11
/// Trait for some basic operations on floats
11
- pub trait Float : Sized + Copy {
12
+ pub trait Float :
13
+ Copy +
14
+ PartialEq +
15
+ PartialOrd +
16
+ ops:: AddAssign +
17
+ ops:: MulAssign +
18
+ ops:: Add < Output = Self > +
19
+ ops:: Sub < Output = Self > +
20
+ ops:: Div < Output = Self > +
21
+ ops:: Rem < Output = Self > +
22
+ {
12
23
/// A uint of the same with as the float
13
24
type Int : Int ;
14
25
26
+ const ZERO : Self ;
27
+ const ONE : Self ;
28
+
15
29
/// The bitwidth of the float type
16
30
const BITS : u32 ;
17
31
@@ -64,6 +78,9 @@ macro_rules! float_impl {
64
78
( $ty: ident, $ity: ident, $bits: expr, $significand_bits: expr) => {
65
79
impl Float for $ty {
66
80
type Int = $ity;
81
+ const ZERO : Self = 0.0 ;
82
+ const ONE : Self = 1.0 ;
83
+
67
84
const BITS : u32 = $bits;
68
85
const SIGNIFICAND_BITS : u32 = $significand_bits;
69
86
You can’t perform that action at this time.
0 commit comments