2

I recently took a computer science test where one question was as follows:

Each RGB color value can range from _____ to _____ in decimal, _____ to _____ in binary and _____ to _____ in hexadecimal.

I answered,

Each RGB color value can range from 0 to 255 in decimal, 0 to 11111111 in binary and 0 to FF in hexadecimal.

But I was marked wrong in the minimums in binary and hexadecimal because I did not provide leading zeros (00000000 and 00, respectively). Am I wrong to say that each RGB color value ranges in those bases from those numbers? My logic is that the number 0 in any base can have any amount of zeros and still correctly represent the number 0, and if that wasn't the case, the minimum for decimal would be 000. The teacher insisted that if you were to develop a website, for example, you would put 00 in hexadecimal for a color value, not 0.

Paradox
  • 23
  • 4

1 Answers1

1

The grading standards of your course are up to your instructor, and it's not the purpose of this site to take a position on grades.

That said, based on what is presented here, my personal view is that you are 100% right, your answer is entirely reasonable, and regardless of your grade, you should go home feeling good about your understanding. Instructors are free to devise grading standards based on how material was taught in the course, and to require that you demonstrate understanding based on the standards established in the course, but absent additional context, the grading standards of the course seem a little lame to me.

For CSS (as used in web pages), the situation is a little complex because of the way that the three RGB values are concatenated. We need a way to distinguish R=1, G=23 from R=12, G=3, and the way we do that is by ensuring that is by ensuring each value has a fixed length (2 hex digits). This is not a property of hex or RGB colors, but a property of the CSS color representation.

D.W.
  • 167,959
  • 22
  • 232
  • 500