• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 324
  • Last Modified:

The symbol '$'???

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
0
viktornet
Asked:
viktornet
  • 9
  • 6
  • 3
  • +1
1 Solution
 
buboiCommented:
'$' indicates a hexadecimal numeral, and it also be used in the compiler directive.
for example, {$R *.dfm}
0
 
viktornetAuthor Commented:
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
0
 
buboiCommented:
for example,
$80 is equal 128,
$f  is equal 15,
$ff is equal 255,
if you want to use some API directly, maybe you need pass some parameters using hex numral, use '$' and hex numral is clear, we needn't tranfer these to dec numrals.


0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
viktornetAuthor Commented:
OK, I'll give you the points... :-), even though I'm still not sure at least you tried, thanx...
0
 
viktornetAuthor Commented:
OK, I'll give you the points... :-), even though I'm still not sure at least you tried, thanx...
0
 
erajojCommented:
Hi,
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

0
 
viktornetAuthor Commented:
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.

Regards,
Viktor Ivanov
0
 
BlackDeathCommented:
i just don't believe this.

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

Black Death.
0
 
viktornetAuthor Commented:
What???

Never mind, forget it....
0
 
viktornetAuthor Commented:
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 ...

0
 
BlackDeathCommented:
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.

0
 
viktornetAuthor Commented:
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

//Vik
0
 
BlackDeathCommented:
ok.
i'm afraid i must have sounded stuck-up 2 ya.
sorry again.

til later & have a nice day,

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

til later & have a nice day,

Black Death.
0
 
viktornetAuthor Commented:
Thanx . U 2

Regards,
Viktor Ivanov
0
 
erajojCommented:
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
0
 
viktornetAuthor Commented:
Hello John! Thanks.Now everything is clear. Finally understood how to convert one to another by hand. Once again thanks, and take care ;)

Regards,
Viktor Ivanov
0
 
BlackDeathCommented:
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?

regards,

Black Death.


0
 
erajojCommented:
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
0
 
BlackDeathCommented:
right you are
bye,
Black Death.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 9
  • 6
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now