Delphi
SECRET, зачем ты брешешь?))
Тимофей Мартынов, мне что код показать? :)
SECRET, покажи
Константин, Вот к примеру быстрая конвертация BCD в double. Работает в 4-5 раз быстрее чем функция, которая в CGate.
scale_arr:array [0..10] of double=
(1,0.01,0.01,0.0001,0.0001,0.000001,0.000001,0.00000001,0.00000001,0.0000000001,0.0000000001);
function BCDToDouble(bcd_data:pointer):double;
var bcd_len:integer;
begin
bcd_len:=((((pByte(bcd_data)+1)^) shr 1)+((((pByte(bcd_data)+1)^) or byte(bcd_data^)) and 1))-1;
case (bcd_len) of
2:
if (((pByte(bcd_data)+2)^ and 128)=128) then
result:=-(((pByte(bcd_data)+2)^ and 127) * bcd_coef[bcd_len] +
(pByte(bcd_data)+3)^ * bcd_coef[bcd_len-1]+
(pByte(bcd_data)+4)^ * bcd_coef[bcd_len-2])*scale_arr[byte(bcd_data^)]
else
result:=((pByte(bcd_data)+2)^ * bcd_coef[bcd_len]+
(pByte(bcd_data)+3)^ * bcd_coef[bcd_len-1]+
(pByte(bcd_data)+4)^ * bcd_coef[bcd_len-2])*scale_arr[byte(bcd_data^)];
3:
if (((pByte(bcd_data)+2)^ and 128)=128) then
result:=-(((pByte(bcd_data)+2)^ and 127) * bcd_coef[bcd_len] +
(pByte(bcd_data)+3)^ * bcd_coef[bcd_len-1]+
(pByte(bcd_data)+4)^ * bcd_coef[bcd_len-2]+
(pByte(bcd_data)+5)^ * bcd_coef[bcd_len-3])*scale_arr[byte(bcd_data^)]
else
result:=((pByte(bcd_data)+2)^ * bcd_coef[bcd_len]+
(pByte(bcd_data)+3)^ * bcd_coef[bcd_len-1]+
(pByte(bcd_data)+4)^ * bcd_coef[bcd_len-2]+
(pByte(bcd_data)+5)^ * bcd_coef[bcd_len-3])*scale_arr[byte(bcd_data^)];
4:
if (((pByte(bcd_data)+2)^ and 128)=128) then
result:=-(((pByte(bcd_data)+2)^ and 127) * bcd_coef[bcd_len] +
(pByte(bcd_data)+3)^ * bcd_coef[bcd_len-1]+
(pByte(bcd_data)+4)^ * bcd_coef[bcd_len-2]+
(pByte(bcd_data)+5)^ * bcd_coef[bcd_len-3]+
(pByte(bcd_data)+6)^ * bcd_coef[bcd_len-4])*scale_arr[byte(bcd_data^)]
else
result:=((pByte(bcd_data)+2)^ * bcd_coef[bcd_len]+
(pByte(bcd_data)+3)^ * bcd_coef[bcd_len-1]+
(pByte(bcd_data)+4)^ * bcd_coef[bcd_len-2]+
(pByte(bcd_data)+5)^ * bcd_coef[bcd_len-3]+
(pByte(bcd_data)+6)^ * bcd_coef[bcd_len-4])*scale_arr[byte(bcd_data^)];
7:
if (((pByte(bcd_data)+2)^ and 128)=128) then
result:=-(((pByte(bcd_data)+2)^ and 127) * bcd_coef[bcd_len] +
(pByte(bcd_data)+3)^ * bcd_coef[bcd_len-1]+
(pByte(bcd_data)+4)^ * bcd_coef[bcd_len-2]+
(pByte(bcd_data)+5)^ * bcd_coef[bcd_len-3]+
(pByte(bcd_data)+6)^ * bcd_coef[bcd_len-4]+
(pByte(bcd_data)+7)^ * bcd_coef[bcd_len-5]+
(pByte(bcd_data)+8)^ * bcd_coef[bcd_len-6]+
(pByte(bcd_data)+9)^ * bcd_coef[bcd_len-7])*scale_arr[byte(bcd_data^)]
else
result:=((pByte(bcd_data)+2)^ * bcd_coef[bcd_len]+
(pByte(bcd_data)+3)^ * bcd_coef[bcd_len-1]+
(pByte(bcd_data)+4)^ * bcd_coef[bcd_len-2]+
(pByte(bcd_data)+5)^ * bcd_coef[bcd_len-3]+
(pByte(bcd_data)+6)^ * bcd_coef[bcd_len-4]+
(pByte(bcd_data)+7)^ * bcd_coef[bcd_len-5]+
(pByte(bcd_data)+8)^ * bcd_coef[bcd_len-6]+
(pByte(bcd_data)+9)^ * bcd_coef[bcd_len-7])*scale_arr[byte(bcd_data^)];
8:
if (((pByte(bcd_data)+2)^ and 128)=128) then
result:=-(((pByte(bcd_data)+2)^ and 127) * bcd_coef[bcd_len] +
(pByte(bcd_data)+3)^ * bcd_coef[bcd_len-1]+
(pByte(bcd_data)+4)^ * bcd_coef[bcd_len-2]+
(pByte(bcd_data)+5)^ * bcd_coef[bcd_len-3]+
(pByte(bcd_data)+6)^ * bcd_coef[bcd_len-4]+
(pByte(bcd_data)+7)^ * bcd_coef[bcd_len-5]+
(pByte(bcd_data)+8)^ * bcd_coef[bcd_len-6]+
(pByte(bcd_data)+9)^ * bcd_coef[bcd_len-7]+
(pByte(bcd_data)+10)^ * bcd_coef[bcd_len-8])*scale_arr[byte(bcd_data^)]
else
result:=((pByte(bcd_data)+2)^ * bcd_coef[bcd_len]+
(pByte(bcd_data)+3)^ * bcd_coef[bcd_len-1]+
(pByte(bcd_data)+4)^ * bcd_coef[bcd_len-2]+
(pByte(bcd_data)+5)^ * bcd_coef[bcd_len-3]+
(pByte(bcd_data)+6)^ * bcd_coef[bcd_len-4]+
(pByte(bcd_data)+7)^ * bcd_coef[bcd_len-5]+
(pByte(bcd_data)+8)^ * bcd_coef[bcd_len-6]+
(pByte(bcd_data)+9)^ * bcd_coef[bcd_len-7]+
(pByte(bcd_data)+10)^ * bcd_coef[bcd_len-8])*scale_arr[byte(bcd_data^)];
12:
if (((pByte(bcd_data)+2)^ and 128)=128) then
result:=-(((pByte(bcd_data)+2)^ and 127) * bcd_coef[bcd_len-3]*bcd_coef[3] +
(pByte(bcd_data)+3)^ * bcd_coef[bcd_len-3]*bcd_coef[2]+
(pByte(bcd_data)+4)^ * bcd_coef[bcd_len-3]*bcd_coef[1]+
(pByte(bcd_data)+5)^ * bcd_coef[bcd_len-3]+
(pByte(bcd_data)+6)^ * bcd_coef[bcd_len-4]+
(pByte(bcd_data)+7)^ * bcd_coef[bcd_len-5]+
(pByte(bcd_data)+8)^ * bcd_coef[bcd_len-6]+
(pByte(bcd_data)+9)^ * bcd_coef[bcd_len-7]+
(pByte(bcd_data)+10)^ * bcd_coef[bcd_len-8]+
(pByte(bcd_data)+11)^ * bcd_coef[bcd_len-9]+
(pByte(bcd_data)+12)^ * bcd_coef[bcd_len-10]+
(pByte(bcd_data)+13)^ * bcd_coef[bcd_len-11]+
(pByte(bcd_data)+14)^ * bcd_coef[bcd_len-12])*scale_arr[byte(bcd_data^)]
else
result:=((pByte(bcd_data)+2)^ * bcd_coef[bcd_len-3]*bcd_coef[3]+
(pByte(bcd_data)+3)^ * bcd_coef[bcd_len-3]*bcd_coef[2]+
(pByte(bcd_data)+4)^ * bcd_coef[bcd_len-3]*bcd_coef[1]+
(pByte(bcd_data)+5)^ * bcd_coef[bcd_len-3]+
(pByte(bcd_data)+6)^ * bcd_coef[bcd_len-4]+
(pByte(bcd_data)+7)^ * bcd_coef[bcd_len-5]+
(pByte(bcd_data)+8)^ * bcd_coef[bcd_len-6]+
(pByte(bcd_data)+9)^ * bcd_coef[bcd_len-7]+
(pByte(bcd_data)+10)^ * bcd_coef[bcd_len-8]+
(pByte(bcd_data)+11)^ * bcd_coef[bcd_len-9]+
(pByte(bcd_data)+12)^ * bcd_coef[bcd_len-10]+
(pByte(bcd_data)+13)^ * bcd_coef[bcd_len-11]+
(pByte(bcd_data)+14)^ * bcd_coef[bcd_len-12])*scale_arr[byte(bcd_data^)];
else result:=0;
end;
end;