@@ -1036,67 +1036,75 @@ pub fn libm() {
10361036 // and thus must be exactly equal to that value
10371037 // C standard says:
10381038 // 1^y = 1 for any y, even a NaN.
1039- assert_eq ! ( 1f32 . powf( 10.0 ) , 1f32 ) ;
1040- assert_eq ! ( 1f64 . powf( 100.0 ) , 1f64 ) ;
1041- assert_eq ! ( 1f32 . powf( f32 :: INFINITY ) , 1f32 ) ;
1042- assert_eq ! ( 1f64 . powf( f64 :: INFINITY ) , 1f64 ) ;
1043- assert_eq ! ( 1f32 . powf( f32 :: NAN ) , 1f32 ) ;
1044- assert_eq ! ( 1f64 . powf( f64 :: NAN ) , 1f64 ) ;
1039+ assert_eq ! ( 1f32 . powf( 10.0 ) , 1.0 ) ;
1040+ assert_eq ! ( 1f64 . powf( 100.0 ) , 1.0 ) ;
1041+ assert_eq ! ( 1f32 . powf( f32 :: INFINITY ) , 1.0 ) ;
1042+ assert_eq ! ( 1f64 . powf( f64 :: INFINITY ) , 1.0 ) ;
1043+ assert_eq ! ( 1f32 . powf( f32 :: NAN ) , 1.0 ) ;
1044+ assert_eq ! ( 1f64 . powf( f64 :: NAN ) , 1.0 ) ;
1045+
1046+
1047+ // For pow (powf in rust) the C standard says:
1048+ // x^0 = 1 for all x even a sNaN
1049+ // FIXME: But the ecosystem is inconistent with this, in the future we should return either
1050+ // 1 or the NaN. Add correct tests when we actually do this.
1051+ // Currently we return 1.
1052+ assert_eq ! ( SINGLE_SNAN . powf( 0.0 ) , 1.0 ) ;
1053+ assert_eq ! ( DOUBLE_SNAN . powf( 0.0 ) , 1.0 ) ;
1054+ // f*::NAN is a quiet NAN and should return 1 as well.
1055+ assert_eq ! ( f32 :: NAN . powf( 0.0 ) , 1.0 ) ;
1056+ assert_eq ! ( f64 :: NAN . powf( 0.0 ) , 1.0 ) ;
1057+
1058+ assert_eq ! ( 42f32 . powf( 0.0 ) , 1.0 ) ;
1059+ assert_eq ! ( 42f64 . powf( 0.0 ) , 1.0 ) ;
1060+ assert_eq ! ( f32 :: INFINITY . powf( 0.0 ) , 1.0 ) ;
1061+ assert_eq ! ( f64 :: INFINITY . powf( 0.0 ) , 1.0 ) ;
10451062
10461063 // For pown (powi in rust) the C standard says:
10471064 // x^0 = 1 for all x not a sNaN.
1048- assert_ne ! ( ( SINGLE_SNAN ) . powi( 0 ) , 1.0 ) ;
1049- assert_ne ! ( ( DOUBLE_SNAN ) . powi( 0 ) , 1.0 ) ;
1050- assert_ne ! ( ( SINGLE_SNAN ) . powi( 0 ) , 1.0 ) ;
1051- assert_ne ! ( ( DOUBLE_SNAN ) . powi( 0 ) , 1.0 ) ;
1052- // f*::NAN is a quiet NAN and should return 1.
1053- assert_eq ! ( f32 :: NAN . powi( 0 ) , 1f32 ) ;
1054- assert_eq ! ( f64 :: NAN . powi( 0 ) , 1f64 ) ;
1055-
1056- assert_eq ! ( ( -1f32 ) . powf( f32 :: INFINITY ) , 1f32 ) ;
1057- assert_eq ! ( ( -1f32 ) . powf( f32 :: NEG_INFINITY ) , 1f32 ) ;
1058- assert_eq ! ( ( -1f64 ) . powf( f64 :: INFINITY ) , 1f64 ) ;
1059- assert_eq ! ( ( -1f64 ) . powf( f64 :: NEG_INFINITY ) , 1f64 ) ;
1060-
1061- assert_eq ! ( 42f32 . powf( 0.0 ) , 1f32 ) ;
1062- assert_eq ! ( 42f32 . powf( -0.0 ) , 1f32 ) ;
1063- assert_eq ! ( 42f64 . powf( 0.0 ) , 1f64 ) ;
1064- assert_eq ! ( 42f64 . powf( -0.0 ) , 1f64 ) ;
1065-
1066- assert_eq ! ( 0f32 . powi( 10 ) , 0f32 ) ;
1067- assert_eq ! ( 0f64 . powi( 100 ) , 0f64 ) ;
1068- assert_eq ! ( 0f32 . powi( 9 ) , 0f32 ) ;
1069- assert_eq ! ( 0f64 . powi( 99 ) , 0f64 ) ;
1070-
1071- // C standard says:
1072- // x^0 = 1, if x is not a Signaling NaN
1073- assert_eq ! ( 10.0f32 . powi( 0 ) , 1.0f32 ) ;
1074- assert_eq ! ( 10.0f64 . powi( 0 ) , 1.0f64 ) ;
1075- assert_eq ! ( f32 :: INFINITY . powi( 0 ) , 1.0f32 ) ;
1076- assert_eq ! ( f64 :: INFINITY . powi( 0 ) , 1.0f64 ) ;
1077-
1078- assert_eq ! ( ( -0f32 ) . powi( 10 ) , 0f32 ) ;
1079- assert_eq ! ( ( -0f64 ) . powi( 100 ) , 0f64 ) ;
1080- assert_eq ! ( ( -0f32 ) . powi( 9 ) , -0f32 ) ;
1081- assert_eq ! ( ( -0f64 ) . powi( 99 ) , -0f64 ) ;
1065+ assert_ne ! ( SINGLE_SNAN . powi( 0 ) , 1.0 ) ;
1066+ assert_ne ! ( DOUBLE_SNAN . powi( 0 ) , 1.0 ) ;
1067+ // f*::NAN is a quiet NAN and should return 1 as well.
1068+ assert_eq ! ( f32 :: NAN . powi( 0 ) , 1.0 ) ;
1069+ assert_eq ! ( f64 :: NAN . powi( 0 ) , 1.0 ) ;
1070+
1071+ assert_eq ! ( 10.0f32 . powi( 0 ) , 1.0 ) ;
1072+ assert_eq ! ( 10.0f64 . powi( 0 ) , 1.0 ) ;
1073+ assert_eq ! ( f32 :: INFINITY . powi( 0 ) , 1.0 ) ;
1074+ assert_eq ! ( f64 :: INFINITY . powi( 0 ) , 1.0 ) ;
1075+
1076+ assert_eq ! ( ( -1f32 ) . powf( f32 :: INFINITY ) , 1.0 ) ;
1077+ assert_eq ! ( ( -1f64 ) . powf( f64 :: INFINITY ) , 1.0 ) ;
1078+ assert_eq ! ( ( -1f32 ) . powf( f32 :: NEG_INFINITY ) , 1.0 ) ;
1079+ assert_eq ! ( ( -1f64 ) . powf( f64 :: NEG_INFINITY ) , 1.0 ) ;
1080+
1081+ assert_eq ! ( 0f32 . powi( 10 ) , 0.0 ) ;
1082+ assert_eq ! ( 0f64 . powi( 100 ) , 0.0 ) ;
1083+ assert_eq ! ( 0f32 . powi( 9 ) , 0.0 ) ;
1084+ assert_eq ! ( 0f64 . powi( 99 ) , 0.0 ) ;
1085+
1086+ assert_eq ! ( ( -0f32 ) . powi( 10 ) , 0.0 ) ;
1087+ assert_eq ! ( ( -0f64 ) . powi( 100 ) , 0.0 ) ;
1088+ assert_eq ! ( ( -0f32 ) . powi( 9 ) , -0.0 ) ;
1089+ assert_eq ! ( ( -0f64 ) . powi( 99 ) , -0.0 ) ;
10821090
10831091 assert_approx_eq ! ( 1f32 . exp( ) , f32 :: consts:: E ) ;
10841092 assert_approx_eq ! ( 1f64 . exp( ) , f64 :: consts:: E ) ;
1085- assert_eq ! ( 0f32 . exp( ) , 1f32 ) ;
1086- assert_eq ! ( 0f64 . exp( ) , 1f64 ) ;
1093+ assert_eq ! ( 0f32 . exp( ) , 1.0 ) ;
1094+ assert_eq ! ( 0f64 . exp( ) , 1.0 ) ;
10871095
10881096 assert_approx_eq ! ( 1f32 . exp_m1( ) , f32 :: consts:: E - 1.0 ) ;
10891097 assert_approx_eq ! ( 1f64 . exp_m1( ) , f64 :: consts:: E - 1.0 ) ;
10901098
10911099 assert_approx_eq ! ( 10f32 . exp2( ) , 1024f32 ) ;
10921100 assert_approx_eq ! ( 50f64 . exp2( ) , 1125899906842624f64 ) ;
1093- assert_eq ! ( 0f32 . exp2( ) , 1f32 ) ;
1094- assert_eq ! ( 0f64 . exp2( ) , 1f64 ) ;
1101+ assert_eq ! ( 0f32 . exp2( ) , 1.0 ) ;
1102+ assert_eq ! ( 0f64 . exp2( ) , 1.0 ) ;
10951103
10961104 assert_approx_eq ! ( f32 :: consts:: E . ln( ) , 1f32 ) ;
10971105 assert_approx_eq ! ( f64 :: consts:: E . ln( ) , 1f64 ) ;
1098- assert_eq ! ( 1f32 . ln( ) , 0f32 ) ;
1099- assert_eq ! ( 1f64 . ln( ) , 0f64 ) ;
1106+ assert_eq ! ( 1f32 . ln( ) , 0.0 ) ;
1107+ assert_eq ! ( 1f64 . ln( ) , 0.0 ) ;
11001108
11011109 assert_approx_eq ! ( 0f32 . ln_1p( ) , 0f32 ) ;
11021110 assert_approx_eq ! ( 0f64 . ln_1p( ) , 0f64 ) ;
0 commit comments