Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

The symbol '$'???

Posted on 1998-07-28
20
Medium Priority
?
323 Views
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;
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
Comment
Question by:viktornet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 6
  • 3
  • +1
20 Comments
 

Expert Comment

by:buboi
ID: 1358923
'$' indicates a hexadecimal numeral, and it also be used in the compiler directive.
for example, {$R *.dfm}
0
 
LVL 10

Author Comment

by:viktornet
ID: 1358924
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
 

Accepted Solution

by:
buboi earned 0 total points
ID: 1358925
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Author Comment

by:viktornet
ID: 1358926
OK, I'll give you the points... :-), even though I'm still not sure at least you tried, thanx...
0
 
LVL 10

Author Comment

by:viktornet
ID: 1358927
OK, I'll give you the points... :-), even though I'm still not sure at least you tried, thanx...
0
 
LVL 4

Expert Comment

by:erajoj
ID: 1358928
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
 
LVL 10

Author Comment

by:viktornet
ID: 1358929
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
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1358930
i just don't believe this.

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

Black Death.
0
 
LVL 10

Author Comment

by:viktornet
ID: 1358931
What???

Never mind, forget it....
0
 
LVL 10

Author Comment

by:viktornet
ID: 1358932
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
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1358933
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
 
LVL 10

Author Comment

by:viktornet
ID: 1358934
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
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1358935
ok.
i'm afraid i must have sounded stuck-up 2 ya.
sorry again.

til later & have a nice day,

Black Death.
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1358936
ok.
i'm afraid i must have sounded stuck-up 2 ya.
sorry again.

til later & have a nice day,

Black Death.
0
 
LVL 10

Author Comment

by:viktornet
ID: 1358937
Thanx . U 2

Regards,
Viktor Ivanov
0
 
LVL 4

Expert Comment

by:erajoj
ID: 1358938
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
 
LVL 10

Author Comment

by:viktornet
ID: 1358939
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
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1358940
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
 
LVL 4

Expert Comment

by:erajoj
ID: 1358941
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
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1358942
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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question