Can someone explain the meaning of using uint32_t from the <stdint.h> library?
I recently saw someones code that used this type of variable and a library for code chef. I was wondering if anyone can explain the benefits of using uint32_t, instead of int, float, doubleetc. Also in what cases should I use / not use it?
Link to code: http://www.codechef.com/viewsolution/131898
The advantage is that it is uint32_talways guaranteed to have a length of 32 bits, in contrast to primitive types, the length of which depends on the platform. For example, while they intare 32 bits on x86 and x86_64, they are 64 bits on many other 64-bit platforms and less than on some old and / or embedded architectures.
One of the cases when it is useful to use uint32_tit may be when you read binary data directly to / from a disk / network. You can always just copy 4 bytes in uint32_tand be sure that it fits. (However, you still have to keep track of differences in content.)
uint32_t, /. , , , .
, , - float32_t float64_t.:)