Page 1 of 1
What are numbers with that $ ?
Posted: Sun Feb 09, 2014 7:33 pm
by nathan78
What kind of numbers are that?
i.e. $00000100
Why not normal numbers?
Re: What are numbers with that $ ?
Posted: Sun Feb 09, 2014 7:36 pm
by Shield
These are hexadecimal numbers, meaning numbers to base 16 instead of 10.

Re: What are numbers with that $ ?
Posted: Sun Feb 09, 2014 7:43 pm
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.
Re: What are numbers with that $ ?
Posted: Sun Feb 09, 2014 7:49 pm
by nathan78
I asking myself why not using 256 instead $00000100.Because its the same.
And $1800 is $00001800 or $18000000?
Re: What are numbers with that $ ?
Posted: Sun Feb 09, 2014 7:57 pm
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.
Re: What are numbers with that $ ?
Posted: Sun Feb 09, 2014 8:17 pm
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.
Re: What are numbers with that $ ?
Posted: Sun Feb 09, 2014 8:42 pm
by luis
I thought $100 meant something was costing one hundred dollars

Re: What are numbers with that $ ?
Posted: Sun Feb 09, 2014 10:06 pm
by HeX0R
luis wrote:I thought $100 meant something was costing one hundred dollars

No, in fact it will cost you 256 dollars

Re: What are numbers with that $ ?
Posted: Mon Feb 10, 2014 2:13 am
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
Re: What are numbers with that $ ?
Posted: Mon Feb 10, 2014 2:47 am
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.