File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -298,10 +298,7 @@ impl Div for Float62 {
298298 return operate_float ( self , rhs, f64:: div) ;
299299 } ;
300300
301- if y == 0 {
302- // TODO Fix this
303- Self :: from_float ( f64:: NAN )
304- } else if x % y == 0 {
301+ if y != 0 && x % y == 0 {
305302 Self :: from_integer ( x / y)
306303 } else {
307304 Self :: from_float ( x as f64 / y as f64 )
@@ -689,7 +686,15 @@ mod tests {
689686
690687 #[ test]
691688 fn div_by_zero ( ) {
692- assert ! ( ( Float62 :: from_integer( 1 ) / Float62 :: from_integer( 0 ) ) . is_nan( ) ) ;
689+ assert_eq ! (
690+ Float62 :: from_integer( 1 ) / Float62 :: from_integer( 0 ) ,
691+ Float62 :: from_float( f64 :: INFINITY )
692+ ) ;
693+ assert_eq ! (
694+ Float62 :: from_integer( -1 ) / Float62 :: from_integer( 0 ) ,
695+ Float62 :: from_float( f64 :: NEG_INFINITY )
696+ ) ;
697+ assert ! ( ( Float62 :: from_integer( 0 ) / Float62 :: from_integer( 0 ) ) . is_nan( ) ) ;
693698 assert_eq ! (
694699 Float62 :: from_float( 6.0 ) / Float62 :: from_integer( 0 ) ,
695700 Float62 :: from_float( f64 :: INFINITY )
You can’t perform that action at this time.
0 commit comments