Unsigned char

From Just Solve the File Format Problem
(Difference between revisions)
Jump to: navigation, search
m
 
(2 intermediate revisions by 2 users not shown)
Line 16: Line 16:
 
| uniform type  =
 
| uniform type  =
 
| conforms to    =  
 
| conforms to    =  
| released      =
+
| released      = 1983
 
| image          =  
 
| image          =  
 
| caption        =  
 
| caption        =  
 
}}
 
}}
 
{{DISPLAYTITLE:unsigned char}}
 
{{DISPLAYTITLE:unsigned char}}
 
+
'''unsigned char''' is the smallest unsigned integer type in C++, it often gets typedef-ed as "byte" (alternatively people use [[signed char]] for that reason) because it uses one byte of memory (depending upon what architecture defines it as, but no less than 8 bits). The range of values that can definitely be stored in this type is 0 – 255.
'''signed char''' is the smallest unsigned integer type in C++, it often gets typedef-ed as "byte" (alternatively people use [[signed char]] for that reason) because it uses one byte of memory (depending upon what architecture defines it as, but no less than 8 bits). The range of values that can definitely be stored in this type is 0 – 255.
+
  
 
{| class='wikitable'
 
{| class='wikitable'

Latest revision as of 11:30, 31 July 2023

File Format
Name unsigned char
Ontology
Released 1983

unsigned char is the smallest unsigned integer type in C++, it often gets typedef-ed as "byte" (alternatively people use signed char for that reason) because it uses one byte of memory (depending upon what architecture defines it as, but no less than 8 bits). The range of values that can definitely be stored in this type is 0 – 255.

7 6 5 4 3 2 1 0 value
1 0 0 0 0 0 0 0 128
0 1 1 1 1 1 1 1 127
0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 255

Operation 255+1 will likely cause a "roll over" and the result will be 0, but it is unwise to count on that when writing multi-architecture code, as it is possible to define byte in a processor to be more than 8 bits.

[edit] Other C++ datatypes of the same size

[edit] Other C++ data types storing unsigned integers

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox