Intent Filters
Intent Filters

Reputation: 189

What does 32bit/8bit and two complement mean when talking about integers?

A book i'm working on keeps on mentioning storing colour values in 24bit or 8 bit integers. I searched through the java docs but all it mentions is that integer/byte are "32-bit signed two's complement integer/8bit signed".Thanks.

Upvotes: 0

Views: 327

Answers (1)

LordOphidian
LordOphidian

Reputation: 178

The books is talking about how the color information is stored, and how many values it can have.

Integers can be stored in many different sized containers, but the most common in C/C++ (and probably Java?) are:

  • 8 bit (i.e. char)
  • 16 bit (i.e. short)
  • 32 bit (i.e. int or long)

In your case, 24bit is referring to the fact that it's using 24 bits to store the color information, which gives you 2^24 color values (16,777,216). Similarly an 8 bit color value can store 256 values.

2's comp refers to the method of representing signed values. See: http://en.wikipedia.org/wiki/Two%27s_complement

Color values are generally unsigned, as far as I know, so it doesn't really apply to your question.

Upvotes: 1

Related Questions