I have 6 u8s (I’ll call them a,b,c,d,e,f) that can each range between 0b1 and 0b1111111. I need to compute the difference of the two groups of 3 as a continuous set of bits i.e. (c..b..a) – (d..e..f).
//my current solution
let left = (c as i32 << 14) + (b as i32 << 7) + (a as i32);
let right = (d as i32 << 14) + (e as i32 << 7) + (f as i32);
return left-right
I need this code to be more performant but I can’t figure out how. The math doesn’t need to be exactly like this I really just need a way to efficiently create a unique i32 from 3 u8s