*
Главная

lifwynnfoundation.org referral Language Basics Data species Integer varieties Char, Short, Int and also Long Types

Char, Short, Int and Long Types
Char, Short, Int and also Long Typeschar

The char kind takes 1 byte of memory (8 bits) and allows expressing in the binary notation 2^8=256 values. The char kind can save both hopeful and an unfavorable values. The range of values is from -128 to 127.

You are watching: How many bytes in a char c

uchar

The uchar integer form also rectal 1 byte that memory, as well as the char type, yet unlike the uchar is intended only for optimistic values. The minimum worth is zero, the maximum value is 255. The first letter u in the surname of the uchar type is the abbreviation for unsigned.

short

The dimension of the short kind is 2 bytes (16 bits) and, accordingly, it allows expressing the variety of values equal come 2 to the power 16: 2^16 = 65 536.Since the short form is a signed one, and also contains both positive and negative values, the variety of values is in between -32 768 and also 32 767.

ushort

The unsigned short kind is the kind ushort, which also has a dimension of 2 bytes. The minimum worth is 0, the maximum worth is 65 535.

int

The size of the int form is 4 bytes (32 bits). The minimal worth is -2 147 483 648, the maximal one is 2 147 483 647.

uint

The unsigned integer type is uint. That takes 4 bytes of memory and enables expressing integers native 0 come 4 294 967 295.

longulong

Examples:


charch=12;shortsh=-5000;intin=2445777;


Since the unsigned integer varieties are no designed because that storing an unfavorable values, the effort to set a an unfavorable value deserve to lead to unexpected consequences. Together a straightforward script will cause an boundless loop:


//---InfiniteloopvoidOnStart()ucharu_ch;for(charch=-128;chu_ch=ch;Print("ch=",ch,"u_ch=",u_ch);


The exactly variant is:


//---CorrectvariantvoidOnStart()ucharu_ch;for(charch=-128;chu_ch=ch;Print("ch=",ch,"u_ch=",u_ch);if(ch==127)break;


Result:


ch=-128u_ch=128ch=-127u_ch=129ch=-126u_ch=130ch=-125u_ch=131ch=-124u_ch=132ch=-123u_ch=133ch=-122u_ch=134ch=-121u_ch=135ch=-120u_ch=136ch=-119u_ch=137ch=-118u_ch=138ch=-117u_ch=139ch=-116u_ch=140ch=-115u_ch=141ch=-114u_ch=142ch=-113u_ch=143ch=-112u_ch=144ch=-111u_ch=145...

See more: 6Th Grade Math Terms That Start With J 6Th Grade Mathematics


Examples:


//---Negativevaluescannotbestoredinunsignedtypesucharu_ch=-120;ushortu_sh=-5000;uintu_in=-401280;


Hexadecimal: numbers 0-9, the letters a-f or A-F because that the worths of 10-15; start with 0x or 0X.