Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

No, char (not signed char, unsigned char, uint8_t or int8_t is the "byte type". By definition.


CHAR_BIT must be at least 8 bits, but is not a "byte" as used by the original comment. The C standard defines "byte" differently from current common usage. To get exactly 8 bits of the desired signedness, which may not be possible on systems with CHAR_BIT greater than 8, one must use [u]int8_t.

----

From a draft version of the C standard:

The typedef name intN_t designates a signed integer type with width N , no padding bits, and a two’s complement representation. Thus, int8_t denotes such a signed integer type with a width of exactly 8 bits.

The typedef name uintN_t designates an unsigned integer type with width N and no padding bits. Thus, uint24_t denotes such an unsigned integer type with a width of exactly 24 bits.

These types are optional. However, if an implementation provides integer types with widths of 8, 16, 32, or 64 bits, no padding bits, and (for the signed types) that have a two’s complement representation, it shall define the corresponding typedef names.


Yes, exactly. Why are you telling me this?

If we're talking about C, we should use the technical definition of "byte" as used by C.

Everywhere else, sure, let's view byte as a 8 bit entity. That's so predominant that everything else would be nit-picking.

But not in the context of the C language.


I was commenting more for the benefit of the original commenter who said there is no "byte" type.


int8_t and uint8_t are definitely not possible on systems with CHAR_BIT greater than 8.

(From 6.2.6.1: Values stored in non-bit-field objects of any other object type consist of n × CHAR_BIT bits, where n is the size of an object of that type, in bytes.)


I believe unsigned char is the byte type, as you're allowed to convert each type into a unsigned char array and read it out (by some standard, was it C99 or C11, I don't know).




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: