一 資料型別

2021-09-26 16:36:33 字數 1064 閱讀 3326

資料超出最大值後得到最小值,超出最小值後得到最大值,本質上是位元組數的限制。

char:1位元組,short:2位元組,int:4位元組,unsigned int:4位元組,long:4位元組,long long:8位元組,float:4位元組,double:8位元組

無符號資料範圍:0至2^(位元組數8)

有符號資料範圍:-2(位元組數*8-1)+1至2(位元組數8-1)

printf("char=%d short=%d int=%d uint=%d long=%d long long=%d float=%d double=%d\n",

sizeof(char),

sizeof(short),

sizeof(int),

sizeof(unsigned int),

sizeof(long),

sizeof(long long),

sizeof(float),

sizeof(double)

);

1. 死迴圈

for(unsigned char i=10; i>=0; i--)

2. 資料相乘容易溢位

char a = 100 * 100;

printf("%d\n", a);

float 4位元組大小

double 8位元組大小

double比較精確

float b=0.01;

double c = 0.01;

printf("%f %lf\n", b, c);

#define value (100000ul)

bit —> char —> int —> long —> float —> double

unsigned —> signed

float d = 10 / 3;

float e = 10 / 3.0;

printf("%f %lf\n", d, e);

printf("%d %d %d %d\n", 10%3, 10%-3, -10%3, -10%-3);

Kotlin資料型別(一 資料型別)

一 boolean boolean型別有兩種型別的 true flase val a boolean true val b boolean false二 number資料型別 package net.println.kotlin author wangdong description number型...

c primer plus 一 資料型別

1.整數 1位元組 8bit 8bit 可以表示0 255或 128 127 short int long short short int long long int c 的標準 short 至少16bit int 至少與short一樣長 long 至少與int一樣長 float 不比double長...

PHP 一 資料型別

php 5 中總共定義了7種資料型別,分別是string 字串 integer 整型 float 浮點型 boolean 布林型 array 陣列 object 物件 null 空值 1 用php的 var dump 函式返回變數的資料型別和值來測驗 x 5985 var dump x int 59...