File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,6 +34,9 @@ macro_rules! define_float_funcs {
3434 /// Special implementation for signum, because libm doesn't have it.
3535 fn signum( self ) -> Self ;
3636
37+ /// Special implementation for `rem_euclid`, because libm doesn't have it.
38+ fn rem_euclid( self , rhs: Self ) -> Self ;
39+
3740 $( fn $name( self $( , $arg: $arg_ty) * ) -> $ret; ) +
3841 }
3942
@@ -51,6 +54,16 @@ macro_rules! define_float_funcs {
5154 }
5255 }
5356
57+ #[ inline]
58+ fn rem_euclid( self , rhs: f32 ) -> f32 {
59+ let r = self % rhs;
60+ if r < 0.0 {
61+ r + rhs. abs( )
62+ } else {
63+ r
64+ }
65+ }
66+
5467 $( fn $name( self $( , $arg: $arg_ty) * ) -> $ret {
5568 #[ cfg( feature = "libm" ) ]
5669 return libm:: $lfname( self $( , $arg as _) * ) ;
@@ -73,6 +86,16 @@ macro_rules! define_float_funcs {
7386 }
7487 }
7588
89+ #[ inline]
90+ fn rem_euclid( self , rhs: f64 ) -> f64 {
91+ let r = self % rhs;
92+ if r < 0.0 {
93+ r + rhs. abs( )
94+ } else {
95+ r
96+ }
97+ }
98+
7699 $( fn $name( self $( , $arg: $arg_ty) * ) -> $ret {
77100 #[ cfg( feature = "libm" ) ]
78101 return libm:: $lname( self $( , $arg as _) * ) ;
You can’t perform that action at this time.
0 commit comments