aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2021-02-07 00:37:58 +0100
committerJulian T <julian@jtle.dk>2021-02-07 00:37:58 +0100
commitf3f56ed5f183f8461cc91cb6430d97c725ba159c (patch)
tree32d07fc105185849b8bf6bfe1fd63bf85f976410 /src/lib.rs
parentb64c7e972c52b7d015d661866f0cf902370343e5 (diff)
Move to double to avoid rounding error
This rounding errors seems to happen when adding floats very close to 1 to a relatively large number. 325.0 + 0.99999034 = 326.0 This is a problem as this sample should be counted at the 325 pixel. However this will be a lesser problem when filtering is implemented.
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 0ec6700..7da6627 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -8,6 +8,7 @@ pub mod sample;
use std::ops::{Add, Sub, Mul, DivAssign, Neg};
use std::cmp;
use std::fmt;
+use std::f64::consts::PI;
/// Trait used to implement generics
///
@@ -25,8 +26,11 @@ pub trait Number:
impl Number for i32 {}
impl Number for f32 {}
+impl Number for f64 {}
/// Used for representing floating point values throughout the program
///
/// A higher precision type will require more ram
-pub type Float = f32;
+pub type Float = f64;
+
+pub const M_PI: Float = PI;