學點 C 語言(13): 資料類型 – 整型、字元型和浮點型的擴充

來源:互聯網
上載者:User
整型 int 可添加 short 和 long:short int:     簡為 short;long int:      簡為 long;long long int: 簡為 long long它們都可以再添加 unsigned:unsigned int:           簡為 unsignedunsigned short int:     簡為 unsigned shortunsigned long int:      簡為 unsigned longunsigned long long int: 簡為 unsigned long longchar 可添加 unsigned:unsigned chardouble 可添加 long:long double

1. short 的最小、最大值:

#include <stdio.h>#include <limits.h>int main(void){    short n1 = SHRT_MIN;    short n2 = SHRT_MAX;    printf("%d .. %d\n", n1,n2);    getchar();    return 0;}

2. long 的最小、最大值:

#include <stdio.h>#include <limits.h>int main(void){    long n1 = LONG_MIN;    long n2 = LONG_MAX;    printf("%ld .. %ld\n", n1,n2);    getchar();    return 0;}

3. long long 的最小、最大值:

#include <stdio.h>#include <limits.h>int main(void){    long long n1 = LLONG_MIN;    long long n2 = LLONG_MAX;    printf("%lld .. %lld\n", n1,n2);    getchar();    return 0;}

4. unsigned 系列的最小值都是 0:

#include <stdio.h>#include <limits.h>int main(void){    unsigned short     n1 = USHRT_MAX;    unsigned           n2 = UINT_MAX;    unsigned long      n3 = ULONG_MAX;    unsigned long long n4 = ULLONG_MAX;    unsigned char       c = UCHAR_MAX;        printf("0 .. %u\n", n1);    printf("0 .. %u\n", n2);    printf("0 .. %lu\n", n3);    printf("0 .. %llu\n", n4);    printf("\n0 .. %u\n", c);        getchar();    return 0;}

5. long double 的最小、最大值:

#include <stdio.h>#include <float.h>int main(void){    long double ld1 = LDBL_MIN;    long double ld2 = LDBL_MAX;    printf("%Le .. %Le\n", ld1,ld2);    getchar();    return 0;}

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.