Thema: Delphi Farbwert zu Dezimal

Einzelnen Beitrag anzeigen

Klaus01

Registriert seit: 30. Nov 2005
Ort: München
5.754 Beiträge
 
Delphi 10.4 Sydney
 
#11

AW: Farbwert zu Dezimal

  Alt 28. Mär 2019, 12:02
Delphi-Quellcode:
var
  test32Bit: cardinal;
  test8Bit: Byte;
begin
  try
    { TODO -oUser -cConsole Main : Insert code here }
    test32Bit := $ABCDEF89;
    test8Bit := (test32Bit shr 24) and $FF;
    writeLn(intToHex(test8Bit));

    test32Bit := $ABCDEF89;
    test8Bit := ((test32Bit and $FF000000) div $1000000) and 255;
    writeln(intToHex(test8Bit));
    readLn;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
Erebnis:
AB
AB

Delphi-Quellcode:
var
  test32Bit: cardinal;
  test8Bit: Byte;
begin
  try
    { TODO -oUser -cConsole Main : Insert code here }
    test32Bit := $ABCDEF89;
    test8Bit := (test32Bit shr 24) and $FF;
    writeLn(intToHex(test8Bit));

    test32Bit := $ABCDEF89;
    test8Bit := ((test32Bit and $FF000000) div $1000000) and 256;
    writeln(intToHex(test8Bit));
    readLn;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.
Ergebnis:
AB
00

Grüße
Klaus
Klaus
  Mit Zitat antworten Zitat