SO . , :
, , [-1.0,1.0]. [-2 ^ 15, (2 ^ 15) -1]. ,
Half = round(0.5*32768); //16384
Third = round((1.0/3.0)*32768); //10923
,
Temp = Half*Third; //178962432
Result = Temp/32768; //5461 = round(1.0/6.0)*32768
32768 - Patros, , . , 2 ^ N:
x1 = x1Float*(2^15);
x2 = x2Float*(2^15);
Temp = x1Float*x2Float*(2^15)*(2^15);
Result = Temp/(2^15); //get back to 2^N scaling
, . , 16- 32- , Temp 32-. , 32768 16- , , 32- . , , / 2,
N = 15;
SInt16 x1 = round(x1Float * (1 << N));
SInt16 x2 = round(x2Float * (1 << N));
SInt32 Temp = x1*x2;
Result = (SInt16)(Temp >> N);
FloatResult = ((double)Result)/(1 << N);
, [-1,1] ? , , [-4.0.4.0), N = 13. 1 , 13 . 1.15 3.13 . .
, . , , . ,
Quotient = (x1/x2) << N;
,
Quotient = (SInt16)(((SInt32)x1 << N)/x2); //x1 << N needs wide storage
. , 6,
Quotient = x1/6; //equivalent to x1Float*(2^15)/6, stays scaled
2,
Quotient = x1 >> 3; //divides by 8, can't do x1 << -3 as Patros pointed out
, , . , x.y, .
, , .