Add a bunch of .round()s before conversions

Previously this was leading to inconsistencies when using f32 v.s. f64
This commit is contained in:
2020-12-17 15:09:53 -08:00
parent 75fde43aa7
commit d8ae766099
5 changed files with 12 additions and 9 deletions

View File

@@ -18,8 +18,8 @@ fn main() {
let current_break = 0.5e-9; // time between 'set' pulse and 'clear' pulse
let conductivity = 1.0e9;
let from_m = |m| (m/feat_size) as u32;
let m_to_um = |px| (px * 1e6) as u32;
let from_m = |m: Flt| (m/feat_size).round() as u32;
let m_to_um = |m: Flt| (m * 1e6).round() as u32;
let half_width = width * 0.5;
let half_depth = depth * 0.5;
@@ -76,8 +76,8 @@ fn main() {
std::mem::size_of::<Flt>() * 8,
*size_px,
m_to_um(feat_size),
(peak_current * 1e3) as i64,
(current_duration * 1e12) as i64,
(peak_current * 1e3).round() as i64,
(current_duration * 1e12).round() as i64,
m_to_um(ferro_major),
m_to_um(ferro_minor),
m_to_um(wire_major),