Comments (9)
Ah ha! This is a point that I didn't explain.
These numbers are in hexidecimal. So it's how you count with them:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- a
- b
- c
- d
- e
- 10
- 11
.... etc.
This is surely something I need to explain a lot better.
from book.
Aha, that makes total sense*! Thank you :)
*in the sense that, I get what you are saying, not why Hex uses 1 2 3 4 5 6 7 8 9 a b c d e 10 11 12 13 to count to 20 :P But I will learn that some day.
from book.
not why Hex uses 1 2 3 4 5 6 7 8 9 a b c d e 10 11 12 13 to count to 20 :P But I will learn that some day.
In mathematics you have different numeral systems with different bases, we commonly use the numeral system with base 10 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9). Other common numeral systems include binary (0, 1), octal (0, 1, 2, 3, 4, 5, 6, 7) and hexadecimal (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f).
Decimal system
To express a number that is higher than 9 in the base 10 numeral system you use a combination of the base digits.
If you want to represent the value 10 you use a combination of the digits "1" and "0" in this case the "1" indicates you have already counted 1 time through all the digits of the numeral system, which is equal to the base. 1 * 10^1 + 0 * 10^0 = 10
If you would have "20" you would have counted through all the digits (base) twice, hence the "2". 2 * 10^1 + 0 * 10^0 = 20
When you have "120" it means you have counted 1 times 10 (base) times through all the digits + 2 times through all the digits 1 * 10^2 + 2 * 10^1 + 0*10^0
"1200" means you have counted one time 10 times 10 times through all the digits + 2 times 10 times through all the digits 1 * 10^3 + 2 * 10^2 + 0 * 10^1 + 0*10^0
.
Binary system
Binary has a base of 2 and works exactly the same.
When you have the binary number "10" you have counted once trough all the digits (0, 1) so you have a value equivalent to 2 in the decimal system. 1 * 2^1 + 0 * 10^0 = 2
"100" means you have counted two times through all the digits, which would equal to 4 in decimal. 1 * 2^2 + 0 * 2^1 + 0 * 2^0 = 4
"1000" you have counted two times twice through all the digits. 1 * 2^3 + 0 * 2^2 + 0 * 2^1 + 0 * 2^0 = 2 * 2 * 2 = 8
Hexadecimal System
Hexadecimal is the same thing again with a base 16, except our language only has 10 symbols representing digits, therefore we use the letters a through f to represent the missing digits. We could have chosen any other symbol really.
So "a" in hexadecimal is equivalent to 10 in decimal, "b" equal to 11, etc.
"10" in hexadecimal does again means you have counted through all the digits once, this is thus equivalent to 16 in decimal.
The decimal 20 would thus be represented as "14" in hexadecimal, because 1 times the base (16) plus 4. 1 * 16^1 + 4 * 16^0 = 20
Decimal 1000 would be "3e8" because 3 times the base (16) times the number of digits (16) + e times the number of digits + 8.
3 * 16^2 + e * 16^1 + 8 * 10^0 = 3 * 256 + 14 * 16 + 8 = 1000
I hope this has clarified some things for you :)
from book.
Wow @azerupi, this is amazing. Thank you for taking time out of your day to write such a considered write up. Have a lovely day ✨
from book.
Awesome explanation! I've already opened an issue for hexadecimal numbers: #22. Perhaps we could move the above explanation into the book itself?
Another possible fix would be to have a separate section with supplemental learning. In the main text we would simply point out that the numbers we're using are hexadecimal and that if you don't know hex numbers or need a review click on the link. The actual explanation would be in another section not part of the main flow of the book. Thoughts?
from book.
Yes, sure that would be no problem. I would not put that in the main text though. Like you proposed, a couple of chapters at the end could explain some topics in more detail that are assumed to be prior knowledge but maybe isn't for everyone. mdBook supports this kind of suffix chapters
If you plan to add this to the book, let me know, I can make a PR with a better formatting and eventually rewrite it a little better. :)
from book.
Yeah, I think adding these as suffix chapters is probably a good idea. That way, if you do know the concept, it's easy to skip.
from book.
Ok, I will try to make a PR in the next couple of days :)
from book.
We need to make sure that the appendix is referenced in the main text when readers are likely to get tripped up on this. Once we have that we can close this issue.
from book.
Related Issues (20)
- [2.3] Toolchain install on Mac OSX
- unknown --nmagic command after setting the $PATH HOT 8
- Translations to Spanish HOT 3
- Latex error... HOT 3
- Book index page needs styles HOT 2
- Review "setting up a development environment"
- "What tools do we use" is awkward
- update for new bootimage HOT 2
- problems with compilation HOT 4
- problems with running qemu HOT 3
- Copy button incorrectly copies to clipboard HOT 2
- Paging explanation HOT 2
- re-sync book with kernel code
- OSX Install Script - Can't unzip objconv HOT 1
- OSX Install Script - can't build grub HOT 1
- some errors in the intro
- Docker appendix?
- update book for new bootloader version
- update theme directory
- Some changes needed in 'creating our first crate'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from book.