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 iTall+short hInt main int argc char argvIncludeInt max(int x int y)Interface calculator public int add(int a int b) class testPublic void drawsquare(int x, int y, int len)DivideintChar short longUnsigned representationShort 자료형 크기Char(255)Bytes charChar 8 bitUnsigned char ascii tableTypedef intLong unsigned int cSigned vs unsigned intWarningConst char *s =Auto break case char