Short Size

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Short Size

1,157 Views
carlosmscabral
Contributor I
Hello there,

Using the compiler option 4-byte integer, a short will have, always, 2 bytes?

I can't understand exactaly the definitions of uint32, uint16... and how the compiler handles them.

Thanks
Labels (1)
0 Kudos
2 Replies

270 Views
admin
Specialist II
> Using the compiler option 4-byte integer, a short will have, always, 2 bytes?
No, this is an architecture dependent.
But, sizeof(short int) is 2 bytes for all known to me 32-bit architectures.
 
> I can't understand exactly the definitions of uint32, uint16... and how the compiler handles them.
Regularly, UINT32 has the range from 0 to 2^31-1.
Regularly, UINT16 has the range from 0 to 2^15-1.
 
0 Kudos

270 Views
JimDon
Senior Contributor III

The purpose of uint32, uint16 etc. is that they are adjusted for the environment you are in so that they are always that size regardless.

So if you use uint32, and you change compilers, processor, or compile options these are adjustedt in one place, vs all over if you use unsigned int.

0 Kudos