Go Down

Topic: What is " uint8_t" ? (Read 76094 times) previous topic - next topic

pakrat

Mar 16, 2009, 04:23 pm Last Edit: Mar 16, 2009, 04:28 pm by potatohead Reason: 1
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.




mem

#1
Mar 16, 2009, 04:30 pm Last Edit: Mar 16, 2009, 04:31 pm by mem Reason: 1
uint8_t is the same as a byte.

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

pakrat

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


Thank you



interlol

#3
Mar 17, 2009, 09:22 am Last Edit: Mar 17, 2009, 09:25 am by interlol Reason: 1
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.

mem

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.

Quote
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 ?

interlol

Quote
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 :D

Go Up