Soyez le premier à donner votre avis sur cette source.
Snippet vu 2 897 fois - Téléchargée 3 fois
unit hexadecimal; uses windows; Interface function Hexbyte(b:byte):string; procedure Hexbyte_pchar(b:byte; pc:pchar); function HexWord(w: Word):string; function Hexlongint_24bits(color:tcolorref):string; function Hexlongint(long: longint):string; function Power(a:real;b:integer):real; function Hexvalue(hex:string):longint; Implementation const hexChars: array [0..$F] of Char='0123456789ABCDEF'; function Hexbyte(b:byte):string; begin hexbyte:=hexChars[b shr 4]+hexChars[b and $F]; end; procedure Hexbyte_pchar(b:byte; pc:pchar); begin pc[0]:=hexChars[b shr 4]; //Shift Right is equivalent with b div 16 pc[1]:=hexChars[b and $F]; //Masque des 4 premier bits pc[2]:=#0; end; function HexWord(w: Word):string; begin hexword:=hexbyte(hi(w))+hexbyte(lo(w)); end; function Hexlongint_24bits(color:tcolorref):string; begin Hexlongint_24bits:=Hexbyte(getrvalue(color))+Hexbyte(getgvalue(color))+Hexbyte(getbvalue(color)); end; function Hexlongint(long: longint):string; begin Hexlongint:=hexword(long shr 16)+hexword(long and $ffff) end; function Power(a:real;b:integer):real; var i:integer; n:real; begin n:=1.0; for i:=1 to b do n:=n*a; power:=n; end; function Hexvalue(hex:string):longint; var i:integer; val:longint; c:char; begin val:=0; for i:=length(hex) downto 1 do begin c:=upcase(hex[i]); case c of '0'..'9': val := round( val + ( ord(c) - ord('0') ) * power(16,length(hex)-i)); 'A'..'F': val := round( val + ( ord(c) - ord('A') + 10 ) * power(16,length(hex)-i)); end; end; HexValue := val; end;
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.