What are uint8_t, uint16_t, uint32_t and uint64_t?

The question is in the title

I don’t know. In what context did you found those?

have you tried googling those terms? what have you found? what’s there that do you not understand?

2 Likes

Are you talking about C? Have you Googled those terms?

well these are datatypes (specifically to Integers) -
e.g. uint8_t : Unsigned Int of 8 bytes
meaning, you can store a Positive Integer with max number being 2^8-1

same for others, all of these are Unsigned Integers and 8, 16,32…etc is the max range 2^n-1

Yeah, I imagine that is what OP would have seen if he Googled, so I was looking for some context and a deeper question since anyone can just Google for themselves.

He may have googled - but may need help with understanding what google spit out.

Right, which is why we asked him if he had questions about what he Googled instead of just Googling it for him?

The purpose of the forum is to help people become programmers. Doing a Google search for someone doesn’t help that person, but working with them to help them understand what they didn’t understand from the results when they Googled is very helpful.

3 Likes

Please don’t assume that everybody does a google search and post the answers. Some may just know.
Also, unsure why you are repeatedly replying with “google search” crap to my posts - wait for the person posing the question to write back instead.
The purpose of this forum is also for everyone to express themselves and not for a few to go about asserting themselves.

FCC promotes the Read, Search, Ask method.

It’s easy to ask a question without trying. In the real world developers live by being able to search and find answers. No one is going to constantly answer questions that can be found with a little research. Now, if you research and don’t understand what was returned then ask for help on what you don’t understand but in that same vein, explain what it is that you didn’t understand rather than asking a search question.

As @JeremyLT said, the purpose of this forum is to help people become programmers and two important things a developer needs to know is how to search and how to read an error message.

(And I feel that by having to reply to someone else this is hijacking the OP’s post since they have yet to respond with what they didn’t understand.)

2 Likes

I’m very sorry, I was feeling kind of restless when I was posting this, hence I didn’t elaborate. Google wasn’t the first thing that came to my mind. I wanted to know about their use cases, again I am very sorry.

No, don’t worry about it, that’s why asked for more clarification. What do you mean by use cases? Do you mean in what context would you use those particular types versus using other similar types?

1 Like

C is an interesting language. There are two things that make your question a little tricky.

Every variable has a type (C is statically typed) but that that type is weakly enforced (C is weakly typed), which means C will implicitly convert, or try to use one type in place of another if the type you assigned to your variable does not match the required type for a function or operator.

Also, C is a very old language, dating back to 1972. This means that conventions and the languages features do not always match.


In theory, you should use an unsigned integer whenever your integer must be positive. The argument to malloc() and alloc() that specifies how big of a size of memory you want to allocate should be unsigned integers (you can’t request -5 bytes of memory). Also, array indices and loop iteration variables are typically positive and could be unsigned integers.

In practice, it has been pretty common (especially in old C programs) to just use int for any integer unless your integer won’t ‘fit’ into an int. By ‘fit’ I mean the values in an int variable must be in between INT_MIN and INT_MAX, -2147483648 and +2147483648 (*with most compilers on most machines, see aside below). In comparison, UINT_MAX is 4294967295, and ULONG_MAX is 18446744073709551615.

Usually, you’ll see int or unsigned int used, unless memory space is limited. An int is a 32 bit integer (*see aside below), but when memory space is limited, sometimes you will see a smaller type, such as uint8_t or a uint16_t, used.


So, in theory you should use a unsigned int when your variable cannot take on a negative value, but in practice you might see int used unless your variable needs to take values larger than INT_MAX (+2147483648). Also, you may see a smaller uint*_t used when memory space is limited on the hardware were your code will run.


*Aside: Depending on the version of the C standard and the compiler implementation of the C standard, these limits above may vary. The C standard is a long, dry, boring document that is a huge pain in the neck to read that describes everything a C compiler must do to correctly implement C.

https://web.archive.org/web/20181230041359if_/http://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf (page 20-22)

In here, an int is actually 16 bits and a long is 32 bits. In practice, a 32 bits is the default integer size for most compilers on most hardware, but this is not strictly matching the C standard. You can use int*_t to get a specific size integer on all compilers (so long as the complier and hardware supports that size).

1 Like

Thanks a ton! I am crystal clear.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.