I've seen some code where they don't use primitive types int, float, double etc. directly. They usually typedef it and use it or use things like uint_8 etc.
Is it really necessary even these days? Or is C/C++ standardized enough that it is preferable to use int, float etc directly.
The uint8 class is primarily meant to store integer values. Most operations that manipulate arrays without changing their elements are defined (examples are reshape , size , subscripted assignment and subscripted reference).
A UINT8 is an 8-bit unsigned integer (range: 0 through 255 decimal).
If the intended use of the variable is to hold an unsigned numerical value, use uint8_t; If the intended use of the variable is to hold a signed numerical value, use int8_t; If the intended use of the variable is to hold a printable character, use char.
A uint8 data type contains all whole numbers from 0 to 255. As with all unsigned numbers, the values must be non-negative. Uint8's are mostly used in graphics (colors are always non-negative).
Because the types like char
, short
, int
, long
, and so forth, are ambiguous: they depend on the underlying hardware. Back in the days when C was basically considered an assembler language for people in a hurry, this was okay. Now, in order to write programs that are portable -- which means "programs that mean the same thing on any machine" -- people have built special libraries of typedefs
and #defines
that allow them to make machine-independent definitions.
The secret code is really quite straight-forward. Here, you have uint_8, which is interpreted
u
for unsigned
int
to say it's treated as a number_8
for the size in bits.In other words, this is an unsigned integer with 8 bits (minimum) or what we used to call, in the mists of C history, an "unsigned char".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With