P 51 char unsigned char short int unsigned Slides: 20 Download presentation 主なデータ型(テキストP. 51) データ型 バイト 表現範囲 char unsigned char short int unsigned int long int unsigned long int float double 1 1 2 2 4 4 4 8 -128~ 127 符号の 有無 整 数 小 数 精度 0~ 255 -32768 ~ 32767 0~ 65535 -2147483648~ 2147483647 0 ~ 4294967295 有効 6桁 有効 15桁 参考:符号つき2進数と符号なし2進数 n 符号なし2進数 ¨ ¨ ¨ 1111 = 255 11111110 = 254 … 10000001 = 128 01111111 = 127 … 00000100 = 4 00000011 = 3 00000010 = 2 00000001 = 1 0000 = 0 n 符号つき2進数 ¨ ¨ ¨ 01111111 = 127 … 00000010 = 2 00000001 = 1 0000 = 0 1111 = -1 11111110 = -2 11111101 = -3 11111100 = -4 … 10000000 = -128 サンプルプログラム3(キャスト) #include <stdio. h> int main(void){ int i 1, i 2; i 1 = 10; i 2 = 3; int / int float / float printf("i 1/i 2=%dn", i 1/i 2); printf("(float)i 1/(float)i 2=%fn", (float)i 1/(float)i 2); return(0); } Int sum(int a int n) int sum=0 iShort short short long long long short short shortInt main int argc char argvChar argvInheritance calculatorPublic void drawsquare(int x, int y, int len)Public int divide(int a int b)Int max(int x int y)Unsigned shortUnsigned charInt long doubleModifier switchUnsigned char in cUnsigned char ascii tableChar(128)Long unsigned int cSigned vs unsigned intUnsigned int c++Typedef intConst int size=18; string *tbl2 = new string[size];Const char * vs char * const