Object-C NSLog 常用输出基本数据类型格式
来源:互联网 发布:python 字符串 大括号 编辑:程序博客网 时间:2024/05/17 07:43
2015/08/19 更新
通过以下输出来查看各数据类型的长度:
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
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:
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
//-------------我是分割线---------------
先上图:
输出语句:
NSLog(@
"%@"
,var);
补充说明:
NSString 类型(字符串) %@
Bool 类型 %i Bool类型值默认为False,即0,为True时输出为1。
Float 类型 %f %0.2f 只保留两位小数
参考链接:
Objective-C Types
- Object-C NSLog 常用输出基本数据类型格式
- Object-C NSLog 常用输出基本数据类型格式
- Objective-C NSLog 输出格式
- Object-c基础之一:#import,NSLog(),数据类型
- 【object-c基础】#import,NSLog(),数据类型
- Objective-C 之NSLog 输出格式
- 【Object C】 基本数据类型
- Object C 基本数据类型
- objective-c基本数据类型之输出格式符
- [IPhone] NSLog输出格式
- NSLog 输出格式!
- NSLog 输出格式
- NSLog 输出格式
- NSLog输出的格式
- NSLog输出格式
- NSLog输出格式
- NSLog 输出格式
- NSLog输出格式详解
- 精通递归程序设计
- 主键与外键
- CSS 和JavaScript 在ie6 ie7 ie8和Firefox下bug兼容解决记录
- linux-多线程--面试题
- Jni使用基础(一)之简单介绍说明
- Object-C NSLog 常用输出基本数据类型格式
- meta http-equiv="Content-Type"什么意思?
- MyBatis的关于批量数据操作的测试
- 在VS2010下安装配置OpenCV2.3 ; 全程截图 + 遇到的问题
- hadoop二次排序
- root用户和user用户的相互切换
- RegisterAttached and Register call on DependencyProperty
- va_list,va_start,va_end处理不定参数函数调用不定参数函数的问题
- Android ERROR: Unknown command 'crunch' 解决方法