We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 29b7b7d commit eb8de33Copy full SHA for eb8de33
src/complex_float.rs
@@ -185,12 +185,12 @@ where
185
}
186
187
fn arg(self) -> Self::Real {
188
- if self > T::zero() {
189
- T::zero()
190
- } else if self < T::zero() {
+ if self.is_nan() {
+ self
+ } else if self.is_sign_negative() {
191
T::PI()
192
} else {
193
- T::nan()
+ T::zero()
194
195
196
@@ -430,6 +430,9 @@ mod test {
430
));
431
432
assert!(closef(ComplexFloat::arg(-1.), core::f64::consts::PI));
433
+ assert!(closef(ComplexFloat::arg(-0.), core::f64::consts::PI));
434
+ assert!(closef(ComplexFloat::arg(0.), 0.));
435
assert!(closef(ComplexFloat::arg(1.), 0.));
436
+ assert!(ComplexFloat::arg(f64::NAN).is_nan());
437
438
0 commit comments