Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

HTML How to Make a Website Customizing Colors and Fonts Use Color in CSS

Anas Rida
Anas Rida
8,183 Points

hexadecimal 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
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

The 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
Anas Rida
8,183 Points

thank 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
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Because I clearly can't type today. I'll edit it for accuracy :P That's a good ol' fashioned typo!

Hello 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:

    • a^2 = 1 * a * a
    • a^1 = 1 * a
    • a^0 = 1
  • Imagine the number 3*3*3 = 3^3 = 27

    • 27 / 3 = 9, so 3^2 is one-third of 27
    • 9 / 3 = 3, so 3^1 is one-third of 9
    • 3 / 3 = 1, so 3^0 is one-third of 3
  • 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
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Alex-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! :thumbsup: