Skip to content

Commit b67f1bd

Browse files
committed
rational: check for NaN when approximating floats
We had a test for NaN already, but thanks to undefined casts (#119) it was only passing by luck -- on armv7hl it failed: https://bugzilla.redhat.com/show_bug.cgi?id=1511187 Now we check for NaN explicitly.
1 parent a203e9f commit b67f1bd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

rational/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ fn approximate_float_unsigned<T, F>(val: F, max_error: F, max_iterations: usize)
774774
// Continued fractions algorithm
775775
// http://mathforum.org/dr.math/faq/faq.fractions.html#decfrac
776776

777-
if val < F::zero() {
777+
if val < F::zero() || val.is_nan() {
778778
return None;
779779
}
780780

0 commit comments

Comments
 (0)