What are numbers with that $ ?

Just starting out? Need help? Post your questions and find answers here.
nathan78
New User
New User
Posts: 4
Joined: Fri Feb 07, 2014 10:38 am

What are numbers with that $ ?

Post by nathan78 »

What kind of numbers are that?

i.e. $00000100

Why not normal numbers?
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: What are numbers with that $ ?

Post by Shield »

These are hexadecimal numbers, meaning numbers to base 16 instead of 10. :)
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
User avatar
spikey
Enthusiast
Enthusiast
Posts: 750
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: What are numbers with that $ ?

Post by spikey »

http://en.wikipedia.org/wiki/Hexadecimal

Hexadecimal notation bears a more obvious relationship to the underlying binary used by the microprocessor than does decimal notation - each hex digit translates to a group of 4 binary digits. Once you get used to working with it, it offers some efficiencies for programmers.
nathan78
New User
New User
Posts: 4
Joined: Fri Feb 07, 2014 10:38 am

Re: What are numbers with that $ ?

Post by nathan78 »

I asking myself why not using 256 instead $00000100.Because its the same.

And $1800 is $00001800 or $18000000?
User avatar
spikey
Enthusiast
Enthusiast
Posts: 750
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: What are numbers with that $ ?

Post by spikey »

At the risk of repeating myself - hexadecimal notation bears a more obvious relationship to the underlying binary used by the microprocessor than does decimal notation.

You can transcribe your example $1800 - always starting from the right hand (least significant digit) end - as:
0000 0000 0000 0000 0001 1000 0000 0000 in binary - its much harder to make the same transcription from a decimal number.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: What are numbers with that $ ?

Post by srod »

Aye, when dealing with bitwise operators, raw binary or decimals are simply too verbose. Hexadecimal is a great compromise.

Take RGB colors for example. The color value 15790320 means nothing to me. Convert to hexadecimal, however (which equates to $F0F0F0) then we quickly see that the intensities of red, green and blue are all equal, meaning we have a shade of grey here. This is but one example of how useful hexadecimal can be.
I may look like a mule, but I'm not a complete ass.
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: What are numbers with that $ ?

Post by luis »

I thought $100 meant something was costing one hundred dollars :shock:
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
HeX0R
Addict
Addict
Posts: 1189
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: What are numbers with that $ ?

Post by HeX0R »

luis wrote:I thought $100 meant something was costing one hundred dollars :shock:
No, in fact it will cost you 256 dollars ;)
User avatar
TI-994A
Addict
Addict
Posts: 2700
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: What are numbers with that $ ?

Post by TI-994A »

nathan78 wrote:I asking myself why not using 256 instead $00000100.Because its the same.
Hi nathan78. You're absolutely right; you can safely use either one in PureBasic.
nathan78 wrote:And $1800 is $00001800 or $18000000? (leading zeroes are ignored)
As with decimal numbers, the leading zeroes are insignificant. You can easily check hexadecimal values with PureBasic's Val() function, like this:

Code: Select all

Debug Val("$1800")      ;6144
Debug Val("$00001800")  ;6144 
Debug Val("$18000000")  ;402653184
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
User avatar
TI-994A
Addict
Addict
Posts: 2700
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: What are numbers with that $ ?

Post by TI-994A »

srod wrote:Take RGB colors for example. The color value 15790320 means nothing to me. Convert to hexadecimal, however (which equates to $F0F0F0) then we quickly see that the intensities of red, green and blue are all equal...
Hi srod. Right as always, although it should be noted that such hexadecimal values are not representational of the conventional R-G-B arrangement.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
Post Reply