Sign in to follow this  
WaleedH95

What does Uint32 mean?

Recommended Posts

Serapth    6671
[quote name='ryan20fun' timestamp='1313776881' post='4851303']
do you mean UINT32 ?
UINT32 is an unsigned int that is 4 bytes long
[/quote]

Just to add to this in case it isnt clear, a byte = 8bits, thus 4 bytes times 8 bits, is the 32 part of uint32.

Share this post


Link to post
Share on other sites
InvalidPointer    1842
Note to OP: At this point in time, the following may be a bit confusing for you, so feel free to skip for now. Realistically, you aren't likely to run across the edge cases below unless you explicitly go off looking to find them.
[quote name='Serapth' timestamp='1313778452' post='4851314']
[quote name='ryan20fun' timestamp='1313776881' post='4851303']
do you mean UINT32 ?
UINT32 is an unsigned int that is 4 bytes long
[/quote]

Just to add to this in case it isnt clear, a byte = 8bits, thus 4 bytes times 8 bits, is the 32 part of uint32.
[/quote]

That isn't exclusively true, no. For most common architectures, that holds, but there are a few more exotic designs (typically in embedded systems) that have bytes be larger or smaller due to indexing concerns. This is why there's all this confusion re: actual sizes of the built-in types for C and C++; the standards were written in such a way that compilers would be free to change this depending on the needs of the hardware while still being source-compatible with other processor targets. Incidentally, sizeof() is also defined so as to return size as multiples of char (also defined to be the smallest native type the architecture supports) for the same reasons, and *NOT* give a value in 8-bit bytes. The More You Know!

The exception to this is the compiler-dependent inttypes.h, which provides a set of variable types guaranteed to be (I believe, I'm no C expert and this isn't in C++ formally) 8, 16, 32 or 64 bits in length. Unless you're working *with those types directly* all bets are off, though with some knowledge of the compiler itself and the target architecture you can take an educated guess.

EDIT: For the sake of completing the Irritable Language Lawyer Nitpickery, some compilers also have extensions (MSVC in particular springs to mind) that also give you some fixed-width types to play around with. If you're using Visual C++, look into __int8, __int16, __int32 and __int64.

Share this post


Link to post
Share on other sites
Slavik81    360
[quote name='InvalidPointer' timestamp='1313780129' post='4851324']That isn't exclusively true, no. For most common architectures, that holds, but there are a few more exotic designs (typically in embedded systems) that have bytes be larger or smaller due to indexing concerns. This is why there's all this confusion re: actual sizes of the built-in types for C and C++; the standards were written in such a way that compilers would be free to change this depending on the needs of the hardware while still being source-compatible with other processor targets. Incidentally, sizeof() is also defined so as to return size as multiples of char (also defined to be the smallest native type the architecture supports) for the same reasons, and *NOT* give a value in 8-bit bytes. The More You Know!
[/quote]
Microsoft defines UINT32 as an integer with the range of 0 to 4294967295. No matter how many bits there are in a char, it's going to be 32-bits (or more, I suppose).
[font="Segoe UI"][size="2"]It might not be 4 bytes on platforms that have different byte sizes, but consider that it's a Microsoft type. Does Microsoft supports any such platforms? I doubt it.[/size][/font]

Share this post


Link to post
Share on other sites
Serapth    6671
Fair enough, I should have been more explicit.

Now, I have never owned a device that didn't have 8bit bytes, but yeah, they do exist and my bad.

For anyone really interested, the limits.h header file should have the limits off all types defined within as implemented by the compiler.

Share this post


Link to post
Share on other sites
Bregma    9214
[quote name='InvalidPointer' timestamp='1313780129' post='4851324']
The exception to this is the compiler-dependent inttypes.h, which provides a set of variable types guaranteed to be (I believe, I'm no C expert and this isn't in C++ formally) 8, 16, 32 or 64 bits in length. Unless you're working *with those types directly* all bets are off, though with some knowledge of the compiler itself and the target architecture you can take an educated guess.
[/quote]
The C standard (section 7.18) requires the standard header <stdint.h> to provide int8_t, in16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, ....
It also mandates [u]int_least[8,16,32,64]_t, [u]int_fast[8,16,32,64]_t, intptr_t, uintptr_t, intmax_t, uintmax_t, and a slew of #defined constants giving the range of all of the above. Standard. If your C compiler does not support the standard, consider moving forward into the 1990s.

The C++ standard mandates the above names in the std:: namespace via the <cstdint> header. It also mandates the same names as well as bool, char, char16_t, char32_t, wchar_t in the :: namespace as as a built-in part of the language along with all the usual signed and unsigned, short and long variants of char and int. Most C++ compilers support the standard in this respect, even though it only became official what, last week? It's not like the new types are surprise, they've been a part of the draft standard for many years.

Those are the standard type names you can depend on. Anything else is a reinvention of the wheel.

Share this post


Link to post
Share on other sites
SiCrane    11839
[quote name='Bregma' timestamp='1313789542' post='4851387']
Most C++ compilers support the standard in this respect, even though it only became official what, last week?
[/quote]
It was announced to be approved in committee on the twelfth, but it hasn't been published yet. They expect it'll be a couple of weeks before it's actually official.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this