What is " uint8_t" ?

What is uint8_t? What is it used for?
It appears to be a designation for integers or functions. I see it used in sketches, such as, "uint8_t count", but am not sure what it does.

uint8_t is the same as a byte.

its shorthand for: a type of unsigned integer of length 8 bits

10 Likes

Posted by: mem Posted on: Today at 17:30:45
uint8_t is the same as a byte.

Thank you

1 Like

More info on the Wikipedia page for Stdint.h.

Basically, <stdint.h> is a new C/C++ header that defines a bunch of cross-platform types that you can use when you need an exact number of bits, with or without the sign.

It's very useful when you do computations on bits, or on specific range of values (in cryptography, or image processing for example) because you don't have to "detect" the size of a long, or an unsigned int, you just "use" what you need. If you want 8 unsigned bits, use uint8_t like you did.

And I insist on the fact that it's cross-platform, you can compile your program on a 64-bits Linux and a 32-bits Windows, and you won't have to change the types.

3 Likes

uint8_t is very useful for cross platform work – but a little cryptic for many Arduino users. I think the byte type is a more Arduino friendly way to express an unsigned 8 bit value.

you can compile your program on a 64-bits Linux and a 32-bits Windows and you won't have to change the types

I think you intended to say: “you can compile your program for ?

2 Likes

I think you intended to say: “you can compile your program for ?

Yes, that's what I meant. My English grammar library still has a few bugs that I intend to iron out with practice :smiley:

7 Likes