Views 1159 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
729 Develop [git] 쉬운 버전관리 Git 설명 hooni 2015.08.18 878
728 Develop [ios] 오브젝티브C→스위프트, 코드 변환 손쉽게 file hooni 2015.08.07 963
» Develop [ios] Objective-C Types & Storage Capacity hooni 2015.07.22 1159
726 Develop [ios] AES256 알고리즘을 이용해 데이터 암호화/복호화 방법 file hooni 2015.07.21 4107
725 Develop [ios] NSData to NSString (NSString to NSData) hooni 2015.07.21 640
724 Develop [ios] WWDC 2015 샘플 소스 코드 통합파일 hooni 2015.07.20 665
723 Develop [android] N-Puzzle 게임 file hooni 2015.07.09 871
722 Develop [android] 코드에서 문자열로 Resource 가져오기 hooni 2015.07.09 3948
721 Develop [android] AlertDialog 메시지 창 띄우기 hooni 2015.07.09 852
720 Develop [c] 이진트리/트리 순회법 코드(전위/중위/후위) 5 file hooni 2015.07.02 20926
719 Develop 정리할 자료. file hooni 2015.07.02 679
718 Develop [ios] NSNotificationCenter 초간단 사용 예~ ㅋㄷ hooni 2015.06.26 657
717 Develop [c] 이진 탐색 두 가지 코드 (재귀/반복) file hooni 2015.06.26 842
716 Develop [c] FSN 온라인 코딩 테스트 (Sorting, Binary Search) file hooni 2015.06.26 1013
715 Develop [ppt] iOS 플라랩#04(2015.06.19) 발표 자료 file hooni 2015.06.04 638
714 Develop Aspect Oriented Programming in Objective-C hooni 2015.05.18 676
Board Pagination Prev 1 ... 6 7 8 9 10 ... 53 Next
/ 53