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;

begin

TempByte := $80;

...

end;

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

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

For example I have a declaration like this:

var TempByte : Byte;

begin

TempByte := $80;

...

end;

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

for example, {$R *.dfm}

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,

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

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.

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.

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

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?

regards,

Black Death.

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.