Views 1151 Votes 0 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print

Code:

@import <limits.h>

// ...

NSLog(@"Primitive sizes:");
NSLog(@"The size of a char is: %d.", sizeof(char));
NSLog(@"The size of short is: %d.", sizeof(short));
NSLog(@"The size of int is: %d.", sizeof(int));
NSLog(@"The size of long is: %d.", sizeof(long));
NSLog(@"The size of long long is: %d.", sizeof(long long));
NSLog(@"The size of a unsigned char is: %d.", sizeof(unsigned char));
NSLog(@"The size of unsigned short is: %d.", sizeof(unsigned short));
NSLog(@"The size of unsigned int is: %d.", sizeof(unsigned int));
NSLog(@"The size of unsigned long is: %d.", sizeof(unsigned long));
NSLog(@"The size of unsigned long long is: %d.", sizeof(unsigned long long));
NSLog(@"The size of a float is: %d.", sizeof(float));
NSLog(@"The size of a double is %d.", sizeof(double));
 
NSLog(@"Ranges:");
NSLog(@"CHAR_MIN: %c", CHAR_MIN);
NSLog(@"CHAR_MAX: %c", CHAR_MAX);
NSLog(@"SHRT_MIN: %hi", SHRT_MIN); // signed short int
NSLog(@"SHRT_MAX: %hi", SHRT_MAX);
NSLog(@"INT_MIN: %i", INT_MIN);
NSLog(@"INT_MAX: %i", INT_MAX);
NSLog(@"LONG_MIN: %li", LONG_MIN); // signed long int
NSLog(@"LONG_MAX: %li", LONG_MAX);
NSLog(@"ULONG_MAX: %lu", ULONG_MAX); // unsigned long int
NSLog(@"LLONG_MIN: %lli", LLONG_MIN); // signed long long int
NSLog(@"LLONG_MAX: %lli", LLONG_MAX);
NSLog(@"ULLONG_MAX: %llu", ULLONG_MAX); // unsigned long long int

 

 

Result:


<32 bit process>
Primitive sizes:
The size of a char is: 1.                
The size of short is: 2.                 
The size of int is: 4.                   
The size of long is: 4.                  
The size of long long is: 8.             
The size of a unsigned char is: 1.       
The size of unsigned short is: 2.        
The size of unsigned int is: 4.          
The size of unsigned long is: 4.         
The size of unsigned long long is: 8.    
The size of a float is: 4.               
The size of a double is 8.               
Ranges:                                  
CHAR_MIN:   -128                         
CHAR_MAX:   127                          
SHRT_MIN:   -32768                       
SHRT_MAX:   32767                        
INT_MIN:    -2147483648                  
INT_MAX:    2147483647                   
LONG_MIN:   -2147483648                  
LONG_MAX:   2147483647                   
ULONG_MAX:  4294967295                   
LLONG_MIN:  -9223372036854775808         
LLONG_MAX:  9223372036854775807          
ULLONG_MAX: 18446744073709551615 


<64 bit process>
Primitive sizes:
The size of a char is: 1.
The size of short is: 2.
The size of int is: 4.
The size of long is: 8.
The size of long long is: 8.
The size of a unsigned char is: 1.
The size of unsigned short is: 2.
The size of unsigned int is: 4.
The size of unsigned long is: 8.
The size of unsigned long long is: 8.
The size of a float is: 4.
The size of a double is 8.
Ranges:
CHAR_MIN:   -128
CHAR_MAX:   127
SHRT_MIN:   -32768
SHRT_MAX:   32767
INT_MIN:    -2147483648
INT_MAX:    2147483647
LONG_MIN:   -9223372036854775808
LONG_MAX:   9223372036854775807
ULONG_MAX:  18446744073709551615
LLONG_MIN:  -9223372036854775808
LLONG_MAX:  9223372036854775807
ULLONG_MAX: 18446744073709551615

 

[출처] https://bhaveshdhaduk.wordpress.com/2014/01/25/ios-objective-c-types/

[참고] http://reference.jumpingmonkey.org/programming_languages/objective-c/types.html

?

List of Articles
No. Category Subject Author Date Views
933 Develop [c] OpenGL 임시로 여기 올림.. hooni 2003.04.23 10324
932 Develop [c] OpenGL 직사각형(2D) 크기 확대/축소 hooni 2003.04.23 9069
931 Develop [c] openssl 샘플코드.. 어려움 ㅠㅠ file hooni 2013.04.23 7018
930 Develop [c] pcapdump 파일 분석 하는 프로그램.. ㅋㅋ file hooni 2013.04.23 6900
929 Develop [c] pcap을 이용한 패킷 분석 ㅎㅎ hooni 2003.04.23 10210
928 Develop [c] RSA 암호화 구현(gmp 라이브러리 활용) file hooni 2016.10.03 880
927 Develop [c] scanf(), printf() 포맷의 형변환 hooni 2003.04.23 10856
926 Develop [c] selec()를 이용한 입출력 다중화 file hooni 2013.04.23 8259
925 Develop [c] SetTimer() & KillTimer() & 일회용 Timer hooni 2013.04.23 9208
924 Develop [c] UCP/TCP 채팅 소스 - 정리해야 함.. file hooni 2003.04.23 7911
923 Develop [c] Unix Domain Socket 을 이용한 IPC hooni 2013.04.23 8011
922 Develop [c] UTF-8을 EUC-KR로 변환.. (iconv) file hooni 2013.04.23 20127
921 Develop [c] vc++ 에서 clrscr(), gotoxy() 함수 사용하기.. hooni 2013.04.23 14254
920 Develop [c] 가변인자 함수(printf와 같은..) hooni 2013.04.23 7171
919 Develop [c] 가위 바위 보 서버, 클라이언트 소스코드 file hooni 2003.04.23 8171
918 Develop [c] 간단한 링크드 리스트(linked list) 자료형 예제.. hooni 2003.04.23 9838
Board Pagination Prev 1 ... 14 15 16 17 18 ... 74 Next
/ 74