Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAnas Rida
8,183 Pointshexadecimal colors interchangability
As mentioned in the video, in the color #5a9a68 for example, the first two characters represent the amount of red in that color. My question is, why does #a59a68 give a different color? the "a5" seems to add more red, hence the more yellowish tint. But if "a" stands for 10, how come 5a and a5 give different amounts of red? Thanks in advance
1 Answer
Jennifer Nordell
Treehouse TeacherThe decimal equivalent of 5a is 90. And the decimal equivalent of a5 is 165. These can be calculated as such (note: I'm using ^ to say to the power of. Ie 2 ^3 = 8):
5a = (16 ^1 * 5 ) + (16 ^0 * 10) = 80 + 10 = 90
a5 = (16 ^1 * 10) + (16^0 * 5) = 160 + 5 = 165
Note: For reasons (even after advance math) I'm unable to explain, any number to the power of 0 is 1. Hope this clarifies why a5 is more red than 5a :) Happy coding!
edited for another note
Your question is a little like why 15 is less than 51 when thinking in decimal terms. But this is a very common question, because none of us count in binary or hexidecimal. Thank goodness!
Anas Rida
8,183 PointsAnas Rida
8,183 Pointsthank you for taking the time to reply to my question. I can see now that they give different values, but I can't figure out why in 5a the second bracket contains 15^, while in a5 the second bracket contains 16^. I know that either way it wouldn't matter, for as you mentioned any number to the power of 0 is 1, but I'm trying to figure out the logic behind this calculation.
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherBecause I clearly can't type today. I'll edit it for accuracy :P That's a good ol' fashioned typo!
alexlazau
10,930 Pointsalexlazau
10,930 PointsHello Jennifer!
Why is any number to the power of 0 1? First of all, a^0 is 1, if you take the principle of permanence. There are more explanations for this:
The 0 means that 1 is not once multiplied with the basis:
Imagine the number 3*3*3 = 3^3 = 27
Imagine a^(n-n) = a^n * a^(-n) = a^n / a^n = 1
I hope I could help. If you are looking into more advanced math, you could take a look at 0^0, which comes with some problems that aren't that easy or even possible to answer.
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherAlex-Christian Lazau Wow! Thanks. No, I haven't been looking into more advanced math. I had plenty at university, I feel. But that explanation makes sense. More than any I ever got from any college professor. I appreciate it!