From b67f1bd6d6cd4e7d302cfdf6c682ca1f1a14c588 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 8 Nov 2017 14:09:05 -0800 Subject: [PATCH] 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. --- rational/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rational/src/lib.rs b/rational/src/lib.rs index 640ca31..ae00142 100644 --- a/rational/src/lib.rs +++ b/rational/src/lib.rs @@ -774,7 +774,7 @@ fn approximate_float_unsigned(val: F, max_error: F, max_iterations: usize) // Continued fractions algorithm // http://mathforum.org/dr.math/faq/faq.fractions.html#decfrac - if val < F::zero() { + if val < F::zero() || val.is_nan() { return None; }