@@ -629,8 +629,9 @@ def test_fmax(self):
629629 self .assertRaises (TypeError , math .fmax , 'x' , 'y' )
630630
631631 self .assertEqual (math .fmax (0. , 0. ), 0. )
632- self .assertEqual (math .fmax (0. , - 0. ), 0. )
633- self .assertEqual (math .fmax (- 0. , 0. ), 0. )
632+ # fmax() does not need to be sensitive to the sign of 0 (F.10.9.2.3).
633+ self .assertIn (math .fmax (0. , - 0. ), {- 0. , 0. })
634+ self .assertIn (math .fmax (- 0. , 0. ), {- 0. , 0. })
634635
635636 self .assertEqual (math .fmax (1. , 0. ), 1. )
636637 self .assertEqual (math .fmax (0. , 1. ), 1. )
@@ -645,26 +646,23 @@ def test_fmax(self):
645646 for x in [NINF , - 1. , - 0. , 0. , 1. , INF ]:
646647 self .assertFalse (math .isnan (x ))
647648
648- with self .subTest (" math.fmax(INF , x)" , x = x ):
649+ with self .subTest (x = x , is_negative = math .copysign ( 1 , x ) < 0 ):
649650 self .assertEqual (math .fmax (INF , x ), INF )
650- with self .subTest ("math.fmax(x, INF)" , x = x ):
651651 self .assertEqual (math .fmax (x , INF ), INF )
652-
653- with self .subTest ("math.fmax(NINF, x)" , x = x ):
654652 self .assertEqual (math .fmax (NINF , x ), x )
655- with self .subTest ("math.fmax(x, NINF)" , x = x ):
656653 self .assertEqual (math .fmax (x , NINF ), x )
657654
658655 @requires_IEEE_754
659656 def test_fmax_nans (self ):
660657 # When exactly one operand is NaN, the other is returned.
661658 for x in [NINF , - 1. , - 0. , 0. , 1. , INF ]:
662- with self .subTest (x = x ):
659+ with self .subTest (x = x , is_negative = math . copysign ( 1 , x ) < 0 ):
663660 self .assertFalse (math .isnan (math .fmax (NAN , x )))
664661 self .assertFalse (math .isnan (math .fmax (x , NAN )))
665662 self .assertFalse (math .isnan (math .fmax (NNAN , x )))
666663 self .assertFalse (math .isnan (math .fmax (x , NNAN )))
667- # When both operands are NaNs, fmax() returns NaN (see C11, F.10.9.2).
664+ # When both operands are NaNs, fmax() returns NaN (see C11, F.10.9.2)
665+ # whose sign is implementation-defined (see C11, F.10.0.3).
668666 self .assertTrue (math .isnan (math .fmax (NAN , NAN )))
669667 self .assertTrue (math .isnan (math .fmax (NNAN , NNAN )))
670668 self .assertTrue (math .isnan (math .fmax (NAN , NNAN )))
@@ -675,8 +673,9 @@ def test_fmin(self):
675673 self .assertRaises (TypeError , math .fmin , 'x' , 'y' )
676674
677675 self .assertEqual (math .fmin (0. , 0. ), 0. )
678- self .assertEqual (math .fmin (0. , - 0. ), - 0. )
679- self .assertEqual (math .fmin (- 0. , 0. ), - 0. )
676+ # fmin() does not need to be sensitive to the sign of 0 (F.10.9.3.1).
677+ self .assertIn (math .fmin (0. , - 0. ), {- 0. , 0. })
678+ self .assertIn (math .fmin (- 0. , 0. ), {- 0. , 0. })
680679
681680 self .assertEqual (math .fmin (1. , 0. ), 0. )
682681 self .assertEqual (math .fmin (0. , 1. ), 0. )
@@ -691,26 +690,23 @@ def test_fmin(self):
691690 for x in [NINF , - 1. , - 0. , 0. , 1. , INF ]:
692691 self .assertFalse (math .isnan (x ))
693692
694- with self .subTest (" math.fmin(INF , x)" , x = x ):
693+ with self .subTest (x = x , is_negative = math .copysign ( 1 , x ) < 0 ):
695694 self .assertEqual (math .fmin (INF , x ), x )
696- with self .subTest ("math.fmin(x, INF)" , x = x ):
697695 self .assertEqual (math .fmin (x , INF ), x )
698-
699- with self .subTest ("math.fmin(NINF, x)" , x = x ):
700696 self .assertEqual (math .fmin (NINF , x ), NINF )
701- with self .subTest ("math.fmin(x, NINF)" , x = x ):
702697 self .assertEqual (math .fmin (x , NINF ), NINF )
703698
704699 @requires_IEEE_754
705700 def test_fmin_nans (self ):
706701 # When exactly one operand is NaN, the other is returned.
707702 for x in [NINF , - 1. , - 0. , 0. , 1. , INF ]:
708- with self .subTest (x = x ):
703+ with self .subTest (x = x , is_negative = math . copysign ( 1 , x ) < 0 ):
709704 self .assertFalse (math .isnan (math .fmin (NAN , x )))
710705 self .assertFalse (math .isnan (math .fmin (x , NAN )))
711706 self .assertFalse (math .isnan (math .fmin (NNAN , x )))
712707 self .assertFalse (math .isnan (math .fmin (x , NNAN )))
713- # When both operands are NaNs, fmin() returns NaN (see C11, F.10.9.3).
708+ # When both operands are NaNs, fmin() returns NaN (see C11, F.10.9.2)
709+ # whose sign is implementation-defined (see C11, F.10.0.3).
714710 self .assertTrue (math .isnan (math .fmin (NAN , NAN )))
715711 self .assertTrue (math .isnan (math .fmin (NNAN , NNAN )))
716712 self .assertTrue (math .isnan (math .fmin (NAN , NNAN )))
0 commit comments