Page 25 - PIC18F4550微處理機C語言設計實務
P. 25
ሔଡ଼ΥႧԊձ C ႧԊ 1
變數型態 所佔位元數 最小值 最大值
unsigned short 16 0 65535
int, signed int 16 –32768 32767
unsigned int 16 0 65535
short oat, signed short long 24 –8388608 8388607
unsigned short long 24 0 16777215
31
long, signed long 32 –2 31 –2 – 1
32
unsigned long 32 0 2 – 1
位元(Bit)資料型態的宣告
Зʩᜊᅰ bit ٙ܁ѓd̙˸ᜫόணࠇ٫܁ѓɓࡈᜊᅰdՉᜊᅰɽʃ݊ɓࡈЗʩ
bitdீཀவࡈ܁ѓމЗʩٙᜊᅰd̙˸࢙Ͼ˲ٜટٙπ՟ɓࡈЗʩf
字元(Character)資料型態的宣告
ίᜊᅰΤ၈ۃࠦᅺͪ chard͜ԸᎷπ 8 Зʩٙοʩאᅰdοʩᇜᇁ˴ࠅԱ
ASCII ڌϾԸfீཀவࡈ܁ѓމοʩٙᜊᅰd̙˸࢙Ͼ˲ٜટٙπ՟ɓࡈЗʩଡ଼ٙ
ʫ࢙f
整數(Integer)變數資料型態的宣告
ίᜊᅰΤ၈ۃࠦᅺͪ int א longίఊ౺˪ʕ float ձ double Ԩʔ੬͜fϾ
short ձ int ί͉ࣣהʧୗԴٙ͜ᇜᙇኜʕdڗܓே݊ 16 ࡈЗʩdΪϤ short ఱʔ੬͜f
Ͼ long މ 4 Зʩଡ଼f
ՉʕϞ̋ᅺͪ unsigned ڌͪՉڗܓΌ͜Ըڌ͍ͪᅰd݂࿁ int ϾԊd࿁ᜊᅰ
abc ٙ܁ѓdԷνjsigned int abcdۆ੭ୌٙᜊᅰ abc Չᅰ࠽ٙڌͪᇍఖ݊ –32768 Ց
32767dϾ unsigned int Չᅰ࠽ٙڌͪᇍఖ݊ 0 Ց 65535f
浮點(Float)變數資料型態的宣告
ՈϞ 24 ࡈЗʩᄱܓٙᅰᜊᅰf
長整數(Long)變數資料型態的宣告
ՈϞ 32 ࡈЗʩᄱܓٙᅰᜊᅰf
signed 與 unsigned
ίᜊᅰ܁ѓٙۨ࿒ୌۃࠦ̋ɪ signed א unsigned ʱйڌͪ༈ᜊᅰ݊੭͍ࠋୌ
אʔ੭͍ࠋୌf
15