//
//  main.m
//  OC_BASE_USEAGE
//
//  Created by Hacker X on 2023/10/22.
//

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        
        NSLog(@"Objective-C 数据类型基本使用");
        //Objective-C 数据类型对应的格式化字符串
        //char -> %c
        //short int -> %hi 10   %hx 16  %ho 8
        //unsigned short int -> %hu 10  %hx 16  %ho  8
        //int -> %hi 10   %hx 16  %ho 8
        //unsigned int   -> %hu 10 %hx 16 %ho 8
        //long int -> %li 10 %lx 16 %lo 8
        //unsigned long int -> %lu 10 %lx 16 %lo 8
        //long long int -> %lli 10 %llx 16 %llo 8
        //unsigned long long int -> %llu 10 %llx 16 %llo 8
        //float -> %f %e %g %a
        //double -> %f %e %g %a
        //long double -> %Lf %Le %Lg
        //id -> %p
        
        NSLog(@"char is : %c",'A');
        //20,1*16+4,2*8+4
        //20,14,24
        NSLog(@"short int is : 十进制:%hi ,十六进制:%hx, 八进制:%ho",20,20,20);
        //十进制,十六进制,八进制,通过十进制格式输出
        NSLog(@"十进制:%hi,十进制:%hi,十进制:%hi",20,0x14,024);
        NSLog(@"十进制:%hi,十进制:%hi,十进制:%hi",-20,-0x14,-024);
        unsigned short int a,b,c;
        a=USHRT_MAX;
        b=-USHRT_MAX;
        c=USHRT_MAX-9999;
        NSLog(@"%hu===,%hu===,%hu",a,b,c);
        
        int d=INT_MAX;
        unsigned int e=UINT_MAX;
        long int g = LONG_MAX;
        long d1 = INTMAX_MAX;
        unsigned long d2 = UINTMAX_MAX;
        unsigned long int h = ULONG_MAX;
        long long int i = LONG_LONG_MAX;
        unsigned long long int j= ULONG_LONG_MAX;
        float k =FLT_MAX;
        double l=DBL_MAX;
        long double m=LDBL_MAX;
        id n = @"this is id object";
        
        NSLog(@"%d,===%u,===%ld,===%lu,===%ld,===%lu",d,e,g,h,d1,d2);
        NSLog(@"%lld\n,%llu\n,%f\n,%f\n,%@\n",i,j,k,l,n);
        NSLog(@"===>>%Lf",m);
        
    }
    return 0;
}

输出:

Objective-C 数据类型基本使用
char is : 65
short int is : 十进制:20 ,十六进制:14, 八进制:24
十进制:20,十进制:20,十进制:20
十进制:-20,十进制:-20,十进制:-20
65,535===,1===,55,536
2,147,483,647,===4,294,967,295,===9,223,372,036,854,775,807,===18,446,744,073,709,551,615,===9,223,372,036,854,775,807,===18,446,744,073,709,551,615
9,223,372,036,854,775,807
,18,446,744,073,709,551,615
,340,282,346,638,528,860,000,000,000,000,000,000,000.0000
,179,769,313,486,231,570,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000.0000
,this is id object
===>>+∞
Program ended with exit code: 0