We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


The symbol '$'???

viktornet asked
Medium Priority
Last Modified: 2010-04-04
Hello all, How are y'all doin'? OK...Here is my question...

1)Can anyone explain what the symbol $ means, and how is it used...

For example I have a declaration like this:
var TempByte : Byte;
  TempByte := $80;
2)Can you tell me how to determine what's the value of that, and if there are any other
ways to use this symbol what are they?

Viktor Ivanov
Watch Question

'$' indicates a hexadecimal numeral, and it also be used in the compiler directive.
for example, {$R *.dfm}


OK tell me something more specific, for example what number is represented by the value $80... I tried this to find out... Edit1.text := IntToStr($80);...but I'm not sure if that's the right value..
And why use hexadecimal instead of a decimal value like 128 or somethin' else... Can you tell me something more specific and I will accept your answer...Thanx..

Viktor Ivanov
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview


OK, I'll give you the points... :-), even though I'm still not sure at least you tried, thanx...


OK, I'll give you the points... :-), even though I'm still not sure at least you tried, thanx...

Just a comment for clarification:
Hexadecimal numbers use 16 as a base while "normal" decimal numbers use 10. These are commonly used by programmers since they are easily converted to/from binary numbers used by the hardware.
Binary "digits" are: 0,1
Decimal "digits" are: 0,1,2,3,4,5,6,7,8,9
Hexadecimal "digits" are: 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f

That makes:
Dec: - Hex:
  0 -   0
  1 -   1
  2 -   2
  3 -   3
  8 -   8
  9 -   9
 10 -   a
 11 -   b
 12 -   c
 13 -   d
 14 -   e
 15 -   f
 16 -  10
 17 -  11
 31 -  1e
 32 -  20
255 -  ff
256 - 100

Bin: - Hex:

00000001 - 01
00000010 - 02
00000011 - 03
00001111 - 0f
00010000 - 10

(do you see the 4:1 connection?)

In Pascal (Delphi) the compiler has to know when the programmer is using decimal representation of the numbers and when he/she uses hexadecimal representation. To do this, the hexadecimal numbers are prefixed with "$". In C/C++ the equivalent is "0x":

Pascal (Delphi):  "$fe"
C/C++          :  "0xfe"

As Buboi is mentioning, the "$" also represents a compiler directive. These have nothing to do with the hexadecimal representation.

A tip: To convert hexadecimal numbers to and from strings use:
  MyHexStr := IntToHex( 254, 2 ); // 254 => 'fe'
  MyInt := StrToInt( '$' + MyHexStr ); // MyHexStr = 'fe' => 254

Hope this doesn't make things worse, but simplify the matter to you.

/// John


Oh, hello! I seem to have forgotten to check the box and haven't recieved the message. Thanks a lot, and that's exactly what I was looking for. Thanks John. I've got a question. Ok let's say I've got 134. without using any calcs, or programming what do you need to do in order to convert the decimal value to hexadecimal. I think first I need to convert it to a binary and then get it's value into hexadecimal. Is that the way it is done or am I missing something? Thanx again. If I hadn't accepted the answer I would've given the points to you.

Viktor Ivanov
i just don't believe this.

vik - pleez tell me that u're takin' the mickey outta us!

Black Death.



Never mind, forget it....


I ain't taking the mickey outta anyone! if you wanna get points just tell me and I'll be happy to give you some... Alright ...

heey vik.
calm down.
u know i ain't hot 4 points.
(i never answered a q, just commented)

what i meant is:
was that a real q, or just a joke?

i didn't mean 2 attack u - 4 heaven's sake!

very sorry if u got that wrong.

Black Death.


It was a question some time ago, but I couldn't get an answer so accepted that guys answer. Anyway, John answered everythin' I needed to know, so I'm really thankful... just didn't get a small part of it, but anyway...who cares..  Talk to ya later

i'm afraid i must have sounded stuck-up 2 ya.
sorry again.

til later & have a nice day,

Black Death.
i'm afraid i must have sounded stuck-up 2 ya.
sorry again.

til later & have a nice day,

Black Death.


Thanx . U 2

Viktor Ivanov

Hi Viktor,
What is it you really lack from my comment?
In the processor there is no difference between a decimal and a hexadecimal number since all is done binary.

If you want to convert 134 to hex "by hand", then do this:

1. Divide number by 16:
  134 / 16 => 8.375
2. Take fractional part of the answer times 16 to get first number.
This is called MODULO (134 mod 16):
  0.375 * 16 => 6 (put this farthest to the right)
3. Repeat the above two steps with the remaining integer part of the answer, until it is 0(zero):
  8 / 16 => 0.5
  0.5 * 16 => 8

This gives the hexadecimal number 86h.


To make it tougher; 51966 in hex is:
  51966 / 16 => 3247.875
  0.875 * 16 => 14 => E (hexadecimal representation of 14, remember?, put this farthest to the right)

  3247 / 16 => 202.9375
  0.9375 * 16 => 15 => F

  202 / 16 => 12.625
  0.625 * 16 => 10 => A

  12 / 16 => 0.75
  0.75 * 16 => 12 => C

That makes C A F E, CAFEh, which is a nice place to go when the coffe provided at work tastes too bad. Lots of nice other "things" there too, if you know what I mean!? >;->

And, BlackDeath...; could you please stop using this strange english syntax? I'm "0" as cool as "U" so I can "0" understand what "U" "R" trying "2" say... ;|

/// John


Hello John! Thanks.Now everything is clear. Finally understood how to convert one to another by hand. Once again thanks, and take care ;)

Viktor Ivanov
sure, john - no problem.

it's just a bad habit from former times.
i'll try and have an eye on it.
but don't be angry when one or the other howler slips in, ok?


Black Death.

No problem!
I'm not that stingy. Just thinking about all those with problems reading the marvelous english language. They're supposed to benefit from this too, right?

/// John
right you are
Black Death.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.