Pages: [1]   Go Down
Author Topic: What is " uint8_t" ?  (Read 52993 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 0
Posts: 126
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.



« Last Edit: March 16, 2009, 10:28:47 am by potatohead » Logged

London
Offline Offline
Faraday Member
**
Karma: 8
Posts: 6240
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

uint8_t is the same as a byte.

its shorthand for: a type of unsigned integer of length 8 bits
« Last Edit: March 16, 2009, 10:31:32 am by mem » Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 126
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Thank you

 
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 27
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: March 17, 2009, 03:25:04 am by interlol » Logged

London
Offline Offline
Faraday Member
**
Karma: 8
Posts: 6240
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 …
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 27
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-grin
Logged

Pages: [1]   Go Up
Jump to:  

Powered by SMF 1.1.19 | SMF © 2013, Simple Machines