From e289da3f599050236ea6b124ab2c97d6f3ad957a Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Sat, 12 Aug 2017 22:19:12 +0200 Subject: Fixed potential index out of bounds error --- src/transforms.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/transforms.rs b/src/transforms.rs index 8c60aad..ceb0bd3 100644 --- a/src/transforms.rs +++ b/src/transforms.rs @@ -87,10 +87,10 @@ fn score_guess(correlation: &[f32], period: f32, data_points: usize) -> f32 { } fn interpolate(correlation: &[f32], x: f32) -> f32 { - if x < 0.0 { + if x.floor() < 0.0 { correlation[0] } - else if x >= correlation.len() as f32 { + else if x.ceil() >= correlation.len() as f32 { correlation[correlation.len()-1] } else { -- cgit v1.2.3