What is the variable/data type for hexadecimal value?


if I want to stock an hexadecimal value (for example: $00000040) into a variable, what kind of variable should I use?


  containshexa: ????;

I have to stock it into the right data type because after, I will use it into a message box, such as
MessageBox(0, PChar('Title'), pchar('Message'), containshexa);

500 points for this one, thx a lot!
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

rfwoolfConnect With a Mentor Commented:
You can just store it as a string and then use something like
rfwoolfConnect With a Mentor Commented:
and then to show it in hex you say

procedure TForm1.Button1Click(Sender: TObject);
  s: String;
  i: Integer;
  s := '$00000060';
  i := StrToInt(s);
  ShowMessage(IntToStr(i)); //it's an integer, so it's displayed in decimal
notation.  $60h=96d
  ShowMessage('$' + IntToHex(i, 8));//show it in hex
Marc582Author Commented:
ok so it means there is not really a variable/data type dedicated to stock hexadecimal value, I really need to use conversion? weird!
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

diniludConnect With a Mentor Commented:
containshexa: Cardinal
MerijnBConnect With a Mentor Sr. Software EngineerCommented:
no, there is no special type. It's exactly the same as a decimal number, it's just displayed differently.
Just use an integer, shortint, cardinal, whatever what you would normally use.
ziolkoConnect With a Mentor Commented:
in addition to MarijnB's comment...

Marc582 your sample $00000040 indicates that it is 4byte long value so to store it you need type which can store at least 4 bytes, but equally important is range of values you want to store

for example if you use Cardinal you will not be able to store negative values
but if you choose Integer you will be able to store neg. values but accepted range is deifferent (-2147483648..2147483647 for Integere against 0..4294967295 for Cardinal)

it is also possible that you don't need all 4 bytes and in $00000040 are some leading zeros.

All Courses

From novice to tech pro — start learning today.