From 79955a19beae54040dd68907807429873fe2c226 Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 16 Jan 2019 16:56:59 +0100 Subject: [PATCH] Fix the no_std f32 errors --- src/calc.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calc.rs b/src/calc.rs index 83a7bd2..06ce44f 100644 --- a/src/calc.rs +++ b/src/calc.rs @@ -55,7 +55,10 @@ impl Calc { let temp_offset = match temp_offset { None => 0i32, Some(offset) if offset == 0.0 => 0i32, - Some(offset) => offset.signum() as i32 * (((((offset.abs() * 100.0) as i32) << 8) - 128) / 5), + Some(offset) => { + let signum: i32 = if offset.gt(&0.0) { 1 } else { -1 }; + signum * (((((offset * 100.0) as i32).abs() << 8) - 128) / 5) + }, }; let t_fine: i32 = (var2 + var3) as i32 + temp_offset;