SE Does Not Like Dissent
SE Does Not Like Dissent

Reputation: 1825

GIF specification unsigned definition

In the GIF specification, here:

http://www.w3.org/Graphics/GIF/spec-gif89a.txt

It refers to 'bytes', which I naturally assume are unsigned chars. If this is the case, what does it refer to when it says 'unsigned'? Unsigned... what? The precise definition is important as it lets me know how many bytes to read in.

Thank you for your time.

Upvotes: 1

Views: 265

Answers (2)

Wooble
Wooble

Reputation: 89897

"unsigned" in the specification refers to a 16-bit integer, with the least significant byte first.

It should probably be noted that in C, unsigned by itself is a synonym for unsigned int, and at the time the GIF specification was written, it was probably reasonable to assume that int on most machines was 16 bits, so it's not entirely unreasonable for them to not define the terms they were using.

Upvotes: 3

Amnon
Amnon

Reputation: 7772

Wherever the word "unsigned" is mentioned in the document, the adjacent diagram shows the number of bytes taken by it. Looks like it's always 2 bytes.

Notice also that the appendix mentions:

Byte Ordering - Unless otherwise stated, multi-byte numeric fields are ordered with the Least Significant Byte first.

Upvotes: 2

Related Questions