@@ -3989,9 +3989,19 @@ pub const fn minnumf128(x: f128, y: f128) -> f128;
3989
3989
/// Therefore, implementations must not require the user to uphold
3990
3990
/// any safety invariants.
3991
3991
#[ rustc_nounwind]
3992
- #[ rustc_intrinsic]
3993
- #[ cfg( not( bootstrap) ) ]
3994
- pub const fn minimumf16 ( x : f16 , y : f16 ) -> f16 ;
3992
+ #[ cfg_attr( not( bootstrap) , rustc_intrinsic) ]
3993
+ pub const fn minimumf16 ( x : f16 , y : f16 ) -> f16 {
3994
+ if x < y {
3995
+ x
3996
+ } else if y < x {
3997
+ y
3998
+ } else if x == y {
3999
+ if x. is_sign_negative ( ) && y. is_sign_positive ( ) { x } else { y }
4000
+ } else {
4001
+ // At least one input is NaN. Use `+` to perform NaN propagation and quieting.
4002
+ x + y
4003
+ }
4004
+ }
3995
4005
3996
4006
/// Returns the minimum (IEEE 754-2019 minimum) of two `f32` values.
3997
4007
///
@@ -4000,9 +4010,19 @@ pub const fn minimumf16(x: f16, y: f16) -> f16;
4000
4010
/// Therefore, implementations must not require the user to uphold
4001
4011
/// any safety invariants.
4002
4012
#[ rustc_nounwind]
4003
- #[ rustc_intrinsic]
4004
- #[ cfg( not( bootstrap) ) ]
4005
- pub const fn minimumf32 ( x : f32 , y : f32 ) -> f32 ;
4013
+ #[ cfg_attr( not( bootstrap) , rustc_intrinsic) ]
4014
+ pub const fn minimumf32 ( x : f32 , y : f32 ) -> f32 {
4015
+ if x < y {
4016
+ x
4017
+ } else if y < x {
4018
+ y
4019
+ } else if x == y {
4020
+ if x. is_sign_negative ( ) && y. is_sign_positive ( ) { x } else { y }
4021
+ } else {
4022
+ // At least one input is NaN. Use `+` to perform NaN propagation and quieting.
4023
+ x + y
4024
+ }
4025
+ }
4006
4026
4007
4027
/// Returns the minimum (IEEE 754-2019 minimum) of two `f64` values.
4008
4028
///
@@ -4011,9 +4031,19 @@ pub const fn minimumf32(x: f32, y: f32) -> f32;
4011
4031
/// Therefore, implementations must not require the user to uphold
4012
4032
/// any safety invariants.
4013
4033
#[ rustc_nounwind]
4014
- #[ rustc_intrinsic]
4015
- #[ cfg( not( bootstrap) ) ]
4016
- pub const fn minimumf64 ( x : f64 , y : f64 ) -> f64 ;
4034
+ #[ cfg_attr( not( bootstrap) , rustc_intrinsic) ]
4035
+ pub const fn minimumf64 ( x : f64 , y : f64 ) -> f64 {
4036
+ if x < y {
4037
+ x
4038
+ } else if y < x {
4039
+ y
4040
+ } else if x == y {
4041
+ if x. is_sign_negative ( ) && y. is_sign_positive ( ) { x } else { y }
4042
+ } else {
4043
+ // At least one input is NaN. Use `+` to perform NaN propagation and quieting.
4044
+ x + y
4045
+ }
4046
+ }
4017
4047
4018
4048
/// Returns the minimum (IEEE 754-2019 minimum) of two `f128` values.
4019
4049
///
@@ -4022,9 +4052,19 @@ pub const fn minimumf64(x: f64, y: f64) -> f64;
4022
4052
/// Therefore, implementations must not require the user to uphold
4023
4053
/// any safety invariants.
4024
4054
#[ rustc_nounwind]
4025
- #[ rustc_intrinsic]
4026
- #[ cfg( not( bootstrap) ) ]
4027
- pub const fn minimumf128 ( x : f128 , y : f128 ) -> f128 ;
4055
+ #[ cfg_attr( not( bootstrap) , rustc_intrinsic) ]
4056
+ pub const fn minimumf128 ( x : f128 , y : f128 ) -> f128 {
4057
+ if x < y {
4058
+ x
4059
+ } else if y < x {
4060
+ y
4061
+ } else if x == y {
4062
+ if x. is_sign_negative ( ) && y. is_sign_positive ( ) { x } else { y }
4063
+ } else {
4064
+ // At least one input is NaN. Use `+` to perform NaN propagation and quieting.
4065
+ x + y
4066
+ }
4067
+ }
4028
4068
4029
4069
/// Returns the maximum (IEEE 754-2008 maxNum) of two `f16` values.
4030
4070
///
@@ -4087,9 +4127,18 @@ pub const fn maxnumf128(x: f128, y: f128) -> f128;
4087
4127
/// Therefore, implementations must not require the user to uphold
4088
4128
/// any safety invariants.
4089
4129
#[ rustc_nounwind]
4090
- #[ rustc_intrinsic]
4091
- #[ cfg( not( bootstrap) ) ]
4092
- pub const fn maximumf16 ( x : f16 , y : f16 ) -> f16 ;
4130
+ #[ cfg_attr( not( bootstrap) , rustc_intrinsic) ]
4131
+ pub const fn maximumf16 ( x : f16 , y : f16 ) -> f16 {
4132
+ if x > y {
4133
+ x
4134
+ } else if y > x {
4135
+ y
4136
+ } else if x == y {
4137
+ if x. is_sign_positive ( ) && y. is_sign_negative ( ) { x } else { y }
4138
+ } else {
4139
+ x + y
4140
+ }
4141
+ }
4093
4142
4094
4143
/// Returns the maximum (IEEE 754-2019 maximum) of two `f32` values.
4095
4144
///
@@ -4098,9 +4147,18 @@ pub const fn maximumf16(x: f16, y: f16) -> f16;
4098
4147
/// Therefore, implementations must not require the user to uphold
4099
4148
/// any safety invariants.
4100
4149
#[ rustc_nounwind]
4101
- #[ rustc_intrinsic]
4102
- #[ cfg( not( bootstrap) ) ]
4103
- pub const fn maximumf32 ( x : f32 , y : f32 ) -> f32 ;
4150
+ #[ cfg_attr( not( bootstrap) , rustc_intrinsic) ]
4151
+ pub const fn maximumf32 ( x : f32 , y : f32 ) -> f32 {
4152
+ if x > y {
4153
+ x
4154
+ } else if y > x {
4155
+ y
4156
+ } else if x == y {
4157
+ if x. is_sign_positive ( ) && y. is_sign_negative ( ) { x } else { y }
4158
+ } else {
4159
+ x + y
4160
+ }
4161
+ }
4104
4162
4105
4163
/// Returns the maximum (IEEE 754-2019 maximum) of two `f64` values.
4106
4164
///
@@ -4109,9 +4167,18 @@ pub const fn maximumf32(x: f32, y: f32) -> f32;
4109
4167
/// Therefore, implementations must not require the user to uphold
4110
4168
/// any safety invariants.
4111
4169
#[ rustc_nounwind]
4112
- #[ rustc_intrinsic]
4113
- #[ cfg( not( bootstrap) ) ]
4114
- pub const fn maximumf64 ( x : f64 , y : f64 ) -> f64 ;
4170
+ #[ cfg_attr( not( bootstrap) , rustc_intrinsic) ]
4171
+ pub const fn maximumf64 ( x : f64 , y : f64 ) -> f64 {
4172
+ if x > y {
4173
+ x
4174
+ } else if y > x {
4175
+ y
4176
+ } else if x == y {
4177
+ if x. is_sign_positive ( ) && y. is_sign_negative ( ) { x } else { y }
4178
+ } else {
4179
+ x + y
4180
+ }
4181
+ }
4115
4182
4116
4183
/// Returns the maximum (IEEE 754-2019 maximum) of two `f128` values.
4117
4184
///
@@ -4120,9 +4187,18 @@ pub const fn maximumf64(x: f64, y: f64) -> f64;
4120
4187
/// Therefore, implementations must not require the user to uphold
4121
4188
/// any safety invariants.
4122
4189
#[ rustc_nounwind]
4123
- #[ rustc_intrinsic]
4124
- #[ cfg( not( bootstrap) ) ]
4125
- pub const fn maximumf128 ( x : f128 , y : f128 ) -> f128 ;
4190
+ #[ cfg_attr( not( bootstrap) , rustc_intrinsic) ]
4191
+ pub const fn maximumf128 ( x : f128 , y : f128 ) -> f128 {
4192
+ if x > y {
4193
+ x
4194
+ } else if y > x {
4195
+ y
4196
+ } else if x == y {
4197
+ if x. is_sign_positive ( ) && y. is_sign_negative ( ) { x } else { y }
4198
+ } else {
4199
+ x + y
4200
+ }
4201
+ }
4126
4202
4127
4203
/// Returns the absolute value of an `f16`.
4128
4204
///
0 commit comments