将double值转换为其字节表示形式的简单方法?我尝试使用如下指针:
var double_v:double; address:^double; .... double_v:=100; address:=@double_v;
但每一个我的概念:如何从地址读取这8个字节,以“AV”结尾.
解决方法
使用“绝对”的两个例子…
用作功能
function GetDoubleByte(MyDouble: Double; Index: Byte): Byte; var Bytes: array[0..7] of Byte absolute MyDouble; begin Result := Bytes[Index]; end; procedure TForm1.Button1Click(Sender: TObject); var MyDouble:Double; DoubleBytes:Array[0..7] of Byte absolute MyDouble; // direct local use begin MyDouble := 17.123; ShowMessage(IntToStr(DoubleBytes[0])); // local usage ShowMessage(IntToStr(GetDoubleByte(MyDouble,0))); // via function call end;