diff options
author | Justin Worthe <justin@worthe-it.co.za> | 2017-08-12 22:19:12 +0200 |
---|---|---|
committer | Justin Worthe <justin@worthe-it.co.za> | 2017-08-12 22:19:12 +0200 |
commit | e289da3f599050236ea6b124ab2c97d6f3ad957a (patch) | |
tree | 8a1146313aad05bd172be8dbdbc09a054c8d7256 /src | |
parent | d23fae9da3da625ca87c615a7798570f138aa0f5 (diff) |
Fixed potential index out of bounds error
Diffstat (limited to 'src')
-rw-r--r-- | src/transforms.rs | 4 |
1 files changed, 2 insertions, 2 deletions
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 { |