Board index » delphi » Dec To HEX

Dec To HEX

I guess you mean as a string, correct.

HexString := Format('%0x',DecValue);

Is what I use.

Mark Bracey

Quote
Henrik Landgren wrote:

> Hi!

> How do I do a function that converts a dec-number to a hex-number in the
> best way?

>  Henrik Landgren, Stockholm - Sweden
>  h...@hem.passagen.se

 

Re:Dec To HEX


Hi!

How do I do a function that converts a dec-number to a hex-number in the
best way?

 Henrik Landgren, Stockholm - Sweden
 h...@hem.passagen.se

Re:Dec To HEX


What I use:

Address := Format('%.4x',[Counter]); // four digits hex

and vice a versa

function Hex2Int(Hex:String) : integer;
var n : integer;
Begin
  val('$'+Hex,Result,n);
  if n<>0 then ShowMessage('Unknown number: '+Hex);
End;

--
Danko Sucevic
LACE SoftwareTeam

Henrik Landgren <h...@hem.passagen.se> wrote in article
<322A0CEF.2...@hem.passagen.se>...

Quote
> Hi!

> How do I do a function that converts a dec-number to a hex-number in the
> best way?

>  Henrik Landgren, Stockholm - Sweden
>  h...@hem.passagen.se

Re:Dec To HEX


The simplest way is built right in to Delphi.  Check out the IntToHex()
function.  :)

--
David S. Becker
ADP Dealer Services (Plaza R&D)
d...@plaza.ds.adp.com
(503)402-3236

Henrik Landgren <h...@hem.passagen.se> wrote in article
<322A0CEF.2...@hem.passagen.se>...

Quote
> Hi!

> How do I do a function that converts a dec-number to a hex-number in the
> best way?

>  Henrik Landgren, Stockholm - Sweden
>  h...@hem.passagen.se

Other Threads