Jump to content


Photo

Hexadecimal: How does FF = 255?


  • Please log in to reply
21 replies to this topic

#1 Compost Deep

Compost Deep

    New Member

  • Normal Members
  • Pip
  • 2 posts

Posted 17 November 2014 - 16:47

I've read a few sites on hexadecimal, and watched some Renoise tutorials. I thought I was with it until I read that FF = 255.

 

I understand that hex is used because it allows for a higher numerical value in a single character space. And it counts 0-9 like normal, and then, A=10, B=11, C=12, D=13, E=14, F=15, and then starts over at 10. So if F=15, then wouldn't FF (15 x 15) equal 225? But if it's the case that hex represents 16 characters, and F represents 16, then FF would equal 256. There's clearlysomething I'm not getting, can anyone help me out?



#2 dblue

dblue

    Dodgy Geezer

  • Admins
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5626 posts
  • Gender:Male
  • Location:Berlin
  • Interests:Code. Music. Graphics.

Posted 17 November 2014 - 16:56

Decimal is base 10
Hexadecimal is base 16

0x0F = 15
0x10 = 16
0x11 = 17
...
0x1F = 31
0x20 = 32
0x21 = 33
...
0x7F = 127
0x80 = 128
0x81 = 129
...
0xFF = 255
0x100 = 256

And so on...


hexadecimalchart1.png

#3 Compost Deep

Compost Deep

    New Member

  • Normal Members
  • Pip
  • 2 posts

Posted 17 November 2014 - 17:06

Okay, now I understand, I was trying to involve more math (based on the decimal system) instead of just counting. Thank you! Feel free to delete this topic.



#4 f+d+k

f+d+k

    Big Super GrandMasta Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPip
  • 716 posts
  • Gender:Not Telling
  • Location:On Land
  • Interests:고추장

Posted 17 November 2014 - 17:22

Okay, now I understand, I was trying to involve more math (based on the decimal system) instead of just counting. Thank you! Feel free to delete this topic.

You almost had it right with math calculating 256. It's the number of distinct values you can have with the 2 digits in hex. -- 0 .. 255 are 256 numbers. :)


  • KMaki likes this

#5 headfunmanager

headfunmanager

    New Member

  • Normal Members
  • Pip
  • 1 posts

Posted 28 May 2017 - 00:06

Actually your premise is correct. 

 

Think about the decimal system.  We call this base 10 but actually the highest individual value is 9.  How do we get 'calculate the value of 99? 10x10, minus 1 to account for the zero place.

 

Now thin about Hex.  We call this base 16 but the highest individual value is F (15 when converted to decimal).  How do we get 'calculate the value of FF? 16x16, minus 1 to account for the zero place.

 

I know that this reply is super late and I'm probably not using the correct technical terms but hopefully it helps someone.  : )


  • globetrotterdk likes this

#6 smasha

smasha

    Member

  • Normal Members
  • PipPip
  • 16 posts

Posted 22 June 2017 - 15:55

Such a complicated system.

 

Renoise is designed for wizz kid Einsteins really not us old musos.



#7 sokoban

sokoban

    Super Advanced Member

  • Normal Members
  • PipPipPipPip
  • 122 posts
  • Gender:Male
  • Location:France

Posted 22 June 2017 - 18:29

255

= 0hFF

= 0b11111111

= 2^7 + 2^6 + 2^5 + 2^4 + 2^3 + 2^2 + 2^1 + 2^0

= 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1


Sokoban - Ghisloban - GhisMart

https://soundcloud.com/ghismart


#8 OopsIFly

OopsIFly

    Guruh Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPip
  • 950 posts
  • Gender:Male
  • Interests:...daydreams... -VS- ...propaganda...

Posted 22 June 2017 - 19:37

lol not wizz kids, those would just use a smartphone + google to convert nowadays. rather old fart oldschool computer freaks. the kind of who invented trackers. it is just the convenience of having bytes within 2 symbols, remember how small computer screens used to be, and also for being able to easily seperate bytes of part of them from each other. is a bit closer to how computers work.

 

it is not such magic, you really just need to half-way know what full/half/quarter/etc range values in hex are. I.e. think of the values as kind of percentages along a scale 0%-100%. And from there how to count a bit along the scale for finder variation. After that you'll be able to use it in trackers. no need to calculate with them in head etc, even nerds use a computer for this nowadays.

 

and the 256 vs 255 confusion stems from the fact, that you would sometimes think about a number, sometimes a count of different possibilities. obviously a byte has 256 different numbers it is able to represent, and within this count the zero is counted as a possible state, too. But you can only represent numbers from 0-255 with it, this is the standard way of using bytes for numbers. like in decimals, you would use for one digit 0..9 actually being 10 different numbers representable.



#9 ffx

ffx

    Guruh Motha Fakka is Levitating and Knows Everything About Renoise Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • 2990 posts
  • Gender:Not Telling
  • Interests:macOS fanboying

Posted 22 June 2017 - 21:09

0x80 + 0x40 = 0xc0

 

Does it help? If you get familiar with it, it's even more simple than decimal!


MacOS 10.12.6 Retina, Renoise 3.1 64 bit   -   Tuned Shortcuts | Multi-Jump From/To Send | Quick Template | Insert Native DSP Menu (incl. deprecated)


#10 sokoban

sokoban

    Super Advanced Member

  • Normal Members
  • PipPipPipPip
  • 122 posts
  • Gender:Male
  • Location:France

Posted 22 June 2017 - 21:16

And for the lulz, if your byte is signed, then FF = -1  :smashed:


Sokoban - Ghisloban - GhisMart

https://soundcloud.com/ghismart


#11 smasha

smasha

    Member

  • Normal Members
  • PipPip
  • 16 posts

Posted 23 June 2017 - 01:22

lol not wizz kids, those would just use a smartphone + google to convert nowadays. rather old fart oldschool computer freaks. the kind of who invented trackers. it is just the convenience of having bytes within 2 symbols, remember how small computer screens used to be, and also for being able to easily seperate bytes of part of them from each other. is a bit closer to how computers work.

 

it is not such magic, you really just need to half-way know what full/half/quarter/etc range values in hex are. I.e. think of the values as kind of percentages along a scale 0%-100%. And from there how to count a bit along the scale for finder variation. After that you'll be able to use it in trackers. no need to calculate with them in head etc, even nerds use a computer for this nowadays.

 

and the 256 vs 255 confusion stems from the fact, that you would sometimes think about a number, sometimes a count of different possibilities. obviously a byte has 256 different numbers it is able to represent, and within this count the zero is counted as a possible state, too. But you can only represent numbers from 0-255 with it, this is the standard way of using bytes for numbers. like in decimals, you would use for one digit 0..9 actually being 10 different numbers representable.

:-(


Edited by smasha, 23 June 2017 - 03:59.


#12 smasha

smasha

    Member

  • Normal Members
  • PipPip
  • 16 posts

Posted 23 June 2017 - 04:04

0x80 + 0x40 = 0xc0

 

Does it help? If you get familiar with it, it's even more simple than decimal!

Yes for you.

Einstein also lol.


Decimal is base 10
Hexadecimal is base 16

0x0F = 15
0x10 = 16
0x11 = 17
...
0x1F = 31
0x20 = 32
0x21 = 33
...
0x7F = 127
0x80 = 128
0x81 = 129
...
0xFF = 255
0x100 = 256

And so on...


attachicon.gifhexadecimalchart1.png

So hard,then came the piano roll.

You are a coder,of course it will be easy for you.


Edited by smasha, 23 June 2017 - 04:05.


#13 danoise

danoise

    Probably More God or Borg Than Human Member

  • Renoise Team
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 6465 posts
  • Gender:Male
  • Location:Berlin
  • Interests:wildlife + urban trekking

Posted 23 June 2017 - 09:25

it is just the convenience of having bytes within 2 symbols, remember how small computer screens used to be

You make it sound like relic of the old age. To me, the advantage of hex is that is goes so well with four. So you can play from a rhythmical offset (slice/Sxx command), all with easily typed numbers like 10,20,30,40 (instead of 16,32,48,64)....hex is easier and faster for these time based things...

Tracking with Stuff. API wishlist | Soundcloud


#14 Garrett Wang

Garrett Wang

    Local Chief Member

  • Normal Members
  • PipPipPipPipPip
  • 216 posts
  • Gender:Male
  • Location:Las Vegas
  • Interests:Science fiction, film and television

Posted 23 June 2017 - 21:58

I think there may have been a tracker from back the day in which the commands went to 256 because 0 represented the value of 1...

 

Why do people write "0x" when they are describing hexamdecimal numbers though?



#15 danoise

danoise

    Probably More God or Borg Than Human Member

  • Renoise Team
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 6465 posts
  • Gender:Male
  • Location:Berlin
  • Interests:wildlife + urban trekking

Posted 23 June 2017 - 22:25

Why do people write "0x" when they are describing hexamdecimal numbers though?

 

It's a convention to make you able to tell that it is in fact hexadecimal. You can't always tell by looking at the number - e.g. 10 could be both. 

Computers especially need this, because, well they need to be told everything, somehow. 


Tracking with Stuff. API wishlist | Soundcloud


#16 sokoban

sokoban

    Super Advanced Member

  • Normal Members
  • PipPipPipPip
  • 122 posts
  • Gender:Male
  • Location:France

Posted 24 June 2017 - 04:13

Why do people write "0x" when they are describing hexamdecimal numbers though?

 

The most common notation seems to be 0x for hexadecimal numbers.

And as said Danoise, this is for reading and programming reasons, since 10 in hexadecimal is 16 in decimal.

 

There are many prefixed notations :

 0x123 (C/C++/C#/Java/assembly), &h123 (Basic), $123 (Pascal), #123 (Lisp, HTML), 0h123 (Texas Instrument), X'123' (Cobol)

 

There are some sufixed notations :

123h (assembly), 123(16) (arithmetic)

 

And even many more  :panic:


Edited by sokoban, 24 June 2017 - 04:14.

Sokoban - Ghisloban - GhisMart

https://soundcloud.com/ghismart


#17 Garrett Wang

Garrett Wang

    Local Chief Member

  • Normal Members
  • PipPipPipPipPip
  • 216 posts
  • Gender:Male
  • Location:Las Vegas
  • Interests:Science fiction, film and television

Posted 25 June 2017 - 00:10

Cool, I always wondered about that because it looks a little like "zero multiplied by...".

 

Hexadecimal is pretty cool and not that bad but ive seen it throw people off quite a lot. They get stressed early on and move on to less capable sequencers.

 

I always thought a non hex based tracker with 24 ticks per line, 96 ticks per beat would work nice.

 

Pretty much like the original software inside the MPC1000 before JJ...except that it would show the all empty space in a tracker sequencer-like way instead of only listing places where events occur. 

 

96ppqn is a good idea for a tracker too!

 

then again, so is the old 12 lines per beat (if the tpl is 6, thats 72ppqn)...ust thinking about ease of triplets and everything.



#18 Dex

Dex

    Member

  • Normal Members
  • PipPip
  • 15 posts

Posted 05 July 2017 - 06:13

To convert a number 0xAB from hex to decimal, just do (16)(A) + B.

 

For instance, 0x84 would be (16)(8) + 4 = 132.

 

Likewise 0xFF would be (16)(15) + 15 = 255



#19 encryptedmind

encryptedmind

    Super Advanced Member

  • Normal Members
  • PipPipPipPip
  • 186 posts
  • Gender:Male
  • Location:India
  • Interests:Jazz, malware, world travel, women

Posted 16 July 2017 - 19:38

Problem : Most schools never clarify the essence of notation systems and the difference between a notation and its intended representation early on and expect people to just catch up later. To make a point its like drawing a round circle with two dots and an arc and calling it a 'face', thus confusing every such drawing as the very definition of 'face'. Things will get clear as you read this post till the end, if things are still unclear, especially to new Renoisers.

Motivation: The simplest way to think of hex notation first is the number of increased symbols to represent more quantity or number of items. Babylonians used a base 60 system so you might imagine it's a lot easier for us. The base of a number representation system really is a count of the total number of items that can be counted using a symbol from the symbol set. Once you get this part, you will suddenly see things very clearly and deal with 'any' base number like base 3 or base 7 or base 93 without any conceptual problems.

Instruction: Let us take a smaller number system like Base 3. The symbols in the symbol set can actually be any graphic or glyph that we like. However by tradition and convention we can certainly reuse existing symbols for familiarity and develop the symbol set. Base 3 = [0,1,2]. While we have 3 symbols, zero does not really denote a quantity but more a lack of or a starting point so in reality this symbol set will only represent 2 items. Why is it this way? Well that is why people tout the invention of zero as something more useful that just a symbol for an item, it effectively represents and empty placeholder or in real life and empty glass/tumbler and the number of items it will hold by virtue of its capacity. Interesting, is not it? This idea was invented or discovered by various cultures in the past but India was the first to 'graphically' symbolise or encode it, this giving birth to an entirely new (then) system of compactly representing numbers.

Now the first question one might ask is why is the last symbol 'less' by one from the base? To answer that, we have to remember that the symbols by themselves do NOT represent the total number of anything unless we attach some significance to it. Rather we take the total 'number' of symbols and use them like a mapping system for the total number of items that can be represented for each individual symbol greater than 0. The total count of symbols greater than 0 is 2, for our base 3 'notation' system. You could make a symbol set like [tumbler,uno,duos] and that would work just as well. Now mapping things from the conceptual world to the circuit and electronics world required some amount of translation agreement or compromise and since switches that go on and off are essentially the next simplest form of encoding that can be done without hardware implementation issues, binary encoding system was developed. You can most definitely make a base 3 or base 9 computer but base 2 makes engineering design simpler and manageable.


Conceptual Visualization: The next step of understanding how to count in a similar base system is also easy and pure arthmetic. Basically you abstract a base number as the length of a drinking cylindrical shape tumbler, which we use to drink water. Also, you subdivide the glass length into carrom pucks that can fit into it.

This very powerful visualisation techniques will mean that for a base 3 system you essentially have a tumbler length that can hold 2 carrom pucks only. Same idea for base 10 or base 16, you have tumbler lengths that hold that many carrom pucks, which is base number-1 excluding the zero symbol, which is a placeholder.

Next step is now basically just using more tumblers to accommodate more carrom pucks to represent or hold higher quantities. So at this point a base (and the 0 symbol) represents a tumbler and the base number-1 the number of carrom pucks that can fit into a tumbler.

 

What next? Say you have your Base 3 glass full with 2 carrom pucks and you want to hold 3 pucks which is the next highest item count from base 3 symbol set, where do you put this 3rd carrom puck? Simplest way is to add another tumbler to your existing tumbler rack and slip a 3rd carrom to this empty tumbler. For sake of convention and consistency, we will add a new tumbler towards the left once the previous tumbler is full. Now at this point you have ALL 3 carrom pucks in the tumblers, but there is a representation issue now. What is it?

Encoding Consistency : Well, here is the distinction made between implementing a holding system and representing one, or notating one. The above arrangement is not at all too different from using the ancient 4 line parallel strokes and slashing the group in between for the 5th line making it very unweildy for large quantities. So the most essential benefit of having this base system of things is that you do not have to take into account each and every line/item that is being counted.

 

How? Well let us just empty the first tumbler and denote the new tumbler with the 3rd puck as 'representing' item 3. Becos to maintain error free encoding of this implementation, the earlier full tumbler must be emptied out so that it will not look it jumped from 3 items to 5 items suddenly. Think about it, it is every intuitive. So now the representation of quantity 3 in base 3 will look like 10. Becos the new tumbler now has only 1 carrom puck and the previous one is now empty, the number is almost like a histogram count of every tumbler basically that has more significance becos of its individual tumbler positions.

That is because each new position represents a new tumbler and each tumbler can hold only so many items, essentially you are using the 'position' of the tumbler to represent batches of items being counted. Now is not that more efficient? So the notation 100 will be 9 items in base 3 where you do not have to notate or store all 9 items but rather just 2 empty tumblers and 1 tumbler with one puck. Compact and nice eh?

This is how things should have been taught in school to everyone so that these conceptual gaps do not exist. If you understand the above, trust me on this one, you already understand the most fundamental and supremely important concepts of the birth of our civilisation and of computer science, and you have a leverage of many CS students or professionals who still have this concept unclear to them and they will always speak in terms of 'dividing the number by the base', but if you ask why, they can't answer!! Try to pry and you will see for yourself.


So back to hex, basically it is a symbol set that uses numerical glyphs like 1,2 and alphabets from our common language to 'represent'more items than what our decimal system does by default. So now we have a mapping issue and much like the example from the base 3 instance above the same process is done for base 16.

0xF represents the 15th item btw. Base 16 means 16 symbols for notation, one for each new item as it is accommodated while counting quantity. Once the 16th value is required to be counted you do the same thing. Place a new 'tumbler' to the left (paying ode to convention and consistency) and empty out the previous tumbler and place the 16th item in the new tumbler. This will effectively 'represent' the 16th item, this making the symbol now 0x10 for 16 items being counted for.

0x prefix is just a human language notation convention to denote base 16. Now you see, 10 in base 3 is 3 items; 10 in hex is 16 items and 10 in decimal is 10 items. See a pattern? The 10 symbol represents the base itself in every base notated this way.

Now why divide or multiply a particular notation symbol by its base to derive other bases. It's basically math common sense. You just take a representation, and decide by the 'tumbler capacity' to get the total number of items that is being counted, which makes sense does it not?

Say for 100 in base 3. By now we know that each new tumbler or position represents the base value in natural powers mostly because of the symmetrical manner in which the items are arranged conceptually. Each tumbler takes a fixed amount and each new position works as an 'accumulator'.

So how we got to 9 items,let us check.

a) 1,2 for the first tumbler and the first two items. Then for the 3rd, we have 10.

 

B) 4th is 11. 5th is 12. 6th is 20. 7th is 21. 8th is 22 and 9th is 100. Get it?

So based on the patterns we see, we can derive a simple formula that works. 1*3^2+0*3^2+0*3^0 = 9 decimals in base 10.

Similarly for the base 16 numbers 0x11 is 17 decimals. The second 1 symbol on the left means that 16 items are already accounted for and the 1 in the previous or first position is a count of the 17th item. Again we can use the patterns that reveal from this techniques and just divide or multiply to map between bases.

The benefit is dance music is using 16 steps or beat subdivisions etc so 0x10 denotes 16 steps and 0x20 will be 32 steps and so on, which is why hex is so better for creative tasks when using computers. Also hex is the native language of all numeric representation in computer engineering above binary which makes you kill two birds with one stone. When you encounter the term "machine word size" it always is in multiples of 4, 8, 16, 32, 64 and so on.

 

Binary looks a lot more easy now does it not? b101 is what? We know from the above analysis and notation pattern that b10 is 2 in Base 2. So filling up each "tumbler" individually we arrive at 5 items :)

 

 

BYTE data type :  0x0 to 0xF takes b0000 to b1111 and taking two such sequences or two hex characters/symbols we get an 8 bit binary pattern which is also known as a BYTE. Taking simple permutations of the binary symbol set to the length of the pattern : b1111 1111 we get 2^8 possible sequences which are unique. So now another popular representation that you get to see is in Prime number calculations where you will always see a number or a range denoted in the similar notation like 2^N-1.  So now you know where this comes from and what it means. The minus one always gives the MAX value of the permutation range. Same for a 2^16 calculation for which the maximum value will be 2^16-1 or 65,535 MAX value from a possible value range of 65,536 values including 0; because this method of caluclation requires 0 to be included and therefore the maximum value is always minus one (for unsigned types). Thus 2^8-1 or 0xFF is 255 decimals.

 

Hope it helps :)


Edited by encryptedmind, 16 July 2017 - 21:13.

encryptedmind

Victor Marak

 

uZIK|mAInD|Z0FTwA-RE


#20 Garrett Wang

Garrett Wang

    Local Chief Member

  • Normal Members
  • PipPipPipPipPip
  • 216 posts
  • Gender:Male
  • Location:Las Vegas
  • Interests:Science fiction, film and television

Posted 18 July 2017 - 01:26

Cool that the babylonians used base 60...The calendar uses duodecimal, like dozens.

But its weird that there were 12 pence per shilling but 20 shillings per pound...you would think it would be 24 shilling per pound.

I heard a bushel is 64 pints...so one pattern in renoise is like a bushel in way, with lines that is.



#21 encryptedmind

encryptedmind

    Super Advanced Member

  • Normal Members
  • PipPipPipPip
  • 186 posts
  • Gender:Male
  • Location:India
  • Interests:Jazz, malware, world travel, women

Posted 18 July 2017 - 02:50

Interesting bit is not it! Btw Aryabhatta from India is credited with the invention of zero(symbol, encoding and concept).

Nothing weird really about 12 pence per shilling. If you take 20 shillings and multiply that by 12 you get 240 pence per Pound, which was the Imperial system. Its just batches of items really whose boundaries are set by government convention.

encryptedmind

Victor Marak

 

uZIK|mAInD|Z0FTwA-RE


#22 Garrett Wang

Garrett Wang

    Local Chief Member

  • Normal Members
  • PipPipPipPipPip
  • 216 posts
  • Gender:Male
  • Location:Las Vegas
  • Interests:Science fiction, film and television

Posted 18 July 2017 - 19:34

Nothing weird really about 12 pence per shilling. If you take 20 shillings and multiply that by 12 you get 240 pence per Pound, which was the Imperial system. Its just batches of items really whose boundaries are set by government convention.

 

Ok. Yeah, that makes sense.

But what about the bushel?


Edited by Garrett Wang, 18 July 2017 - 19:37.