function ReverseString(const AText: string): string; var I: Integer; P: PChar; begin SetLength(Result, Length(AText)); P := PChar(Result); for I := Length(AText) downto 1 do begin P^ := AText[I]; Inc(P); end; end; //*)
function HexToStr(mHex: string): string; var I: Integer; begin Result := ''; for I := 1 to Length(mHex) div 2 do Result := Result + Chr(StrToIntDef('$' + Copy(mHex, I * 2 - 1, 2), 0)); end; { HexToStr }
function HexToSingle(mHex: string): Single; var S: string; begin S := ReverseString(HexToStr(mHex)); Move(S[1], Result, 4); end;
procedure TForm3.Button1Click(Sender: TObject); begin label134.text:= FormatFloat('#.00', HexToSingle('4085C28F')); end;
----------------------------------------------
-
function HexToSingleA(const hex: string): single; var i : Integer; FloatValue: Single absolute i; begin i := StrToInt('$' + hex); Result := FloatValue; end;