Some compilers and hardware are supported multiplication and floating point arithmetic, it is also very convenient to use! The only thing that makes me unhappy is that it occupies ROM! So some platforms can be converted by shifting!
Learning to calculate the experience:
The denominator is set for the 2 squared case! 2.4.8.16.32.64.128.256.512.1024.2048 ...
Shift left 1 is equal to 2 left shift 2 bit equal to 4 left shift 3 bit equivalent times 8 left shift 4 bit equals multiplied by 16 ... is a summation, multiplied by the sum of squares of 2
Shift right 1 bits equal to 2 right Shift 2 bits equals 4 right Shift 3 bits equals 8 right shift 4 bits equal divided by 16 ... is reduced by a reduction, multiplied by 2 squared
Class One: temperature conversion in lm75a temperature sensor!
1, reserved two decimal point value =t*0.125; 0.125 is one of 8 points multiplied by 100 = 8 per cent t =value * 100;
t = (t << 6) + (T << 5) + (T << 2); 4 -----just over t = t>>3; equivalent to 8
2, reserved a decimal point
Value =t*1.25; 1.25 is 4 of the 5 equivalent t = (t << 2) + t; 4 t = t >> 2;
Class Two: temperature conversion in the DS18B20 temperature sensor!
1, reserved two decimal point value =t*0.0625;
T =value * 100; t = 1/16 * 100 = 25/4;
Equivalent
t = (t << 4) + (T << 3) + t; 8 1 just to
t = t>>2; equivalent to 4
2, reserved a decimal point
value =t*0.628; 0.628 is 8 by 5 equivalent to T = (T << 2) + t; 4 t = t >> 3; Equivalent to 8
C-Binary division is represented by left and right shifts