var B : array [0..3] of byte; F : Single; begin B[0] := .. B[1] := .. ... F := PSingle(@B)^;//这样就行了 end;
数据结构除了用指针,也可以用可变记录类型 //短整形 TWordRec = record case Integer of 0:(vw:Word); 1:(bL,bH:Byte); end; //单精度浮点数(4字节) TSingleRec = record case Integer of 0:(Value:Single); 1:(bLL,bLH,bHL,bHH:Byte); end; //双精度浮点数(8字节) TDoubleRec = record case Integer of 0:(Value:Double); 1:(blLL,blLH,blHL,blHH,bhLL,bhLH,bhHL,bhHH:Byte); end;注意下计算机中的数是按从低到高的字节顺序存储的就好。
B : array [0..3] of byte;
F : Single;
begin
B[0] := ..
B[1] := ..
...
F := PSingle(@B)^;//这样就行了
end;
//短整形
TWordRec = record
case Integer of
0:(vw:Word);
1:(bL,bH:Byte);
end;
//单精度浮点数(4字节)
TSingleRec = record
case Integer of
0:(Value:Single);
1:(bLL,bLH,bHL,bHH:Byte);
end;
//双精度浮点数(8字节)
TDoubleRec = record
case Integer of
0:(Value:Double);
1:(blLL,blLH,blHL,blHH,bhLL,bhLH,bhHL,bhHH:Byte);
end;注意下计算机中的数是按从低到高的字节顺序存储的就好。