ObjCデータ型のテスト
3075 ワード
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// Hello, World!
NSLog(@"Hello, World!");
int integerVar = 100;
float floatingVar = 331.79;
double doubleVar = 8.44e+11;
char charVar = 'W';
long int numberOfPoints = 131071100L;
// numberOfPoints = 131071100
NSLog(@"numberOfPoints = %li", numberOfPoints);
// integarVar = 100
NSLog(@"integarVar = %i", integerVar);
// floatingVar = 331.790009
NSLog(@"floatingVar = %f", floatingVar);
// doubleVar = 8.440000e+11
NSLog(@"doubleVar = %e", doubleVar);
// doubleVar = 8.44e+11
NSLog(@"doubleVar = %g", doubleVar);
// charVar = W
NSLog(@"charVar = %c", charVar);
long long int maxAllowStorage = 1.000e+63-1;
// maxAllowStorage = 9223372036854775807
NSLog(@"maxAllowStorage = %lli", maxAllowStorage);
long double US_deficit_2004 = 1.234e+7l;
// US_deficit_2004 = 12340000.000000 1.234000e+07 1.234e+07
NSLog(@"US_deficit_2004 = %Lf %Le %Lg", US_deficit_2004, US_deficit_2004, US_deficit_2004);
short int shortInt = 7374;
// shortInt = 7374 16316 1cce
NSLog(@"shortInt = %hi %ho %hx", shortInt, shortInt, shortInt);
unsigned int counter = 0x00ffu;
// counter = 255
NSLog(@"counter = %u", counter);
unsigned long temp = 200000ul;
// temp = 200000, sizeof(temp) = 8
NSLog(@"temp = %lu, sizeof(temp) = %lu", temp, sizeof(temp));
char a = 'a', c = '
';
// a = a, c =
NSLog(@"a = %c, c = %c", a, c);
unsigned long long int u12 = 12ull, ffee = 0xffeeULL;
// u12 = 12, c, 14, ffee = 65518, ffee, 177756
NSLog(@"u12 = %llu, %llx, %llo, ffee = %llu, %llx, %llo", u12, u12, u12, ffee, ffee, ffee);
float fl1 = 12.34f, fl2 = 0x1p-2;
// 12.340000 1.234000e+01 12.34 0x1.8ae148p+3
NSLog(@"%f %e %g %a", fl1, fl1, fl1, fl1);
// 0.250000 2.500000e-01 0.25 0x1p-2
NSLog(@"%f %e %g %a", fl2, fl2, fl2, fl2);
double db1 = 12.34, db2 = 3.1e-5, db3 = 0x.1p3;
// db1 = 12.340000 1.234000e+01 12.34 0x1.8ae147ae147aep+3
NSLog(@"db1 = %f %e %g %a", db1, db1, db1, db1);
// db2 = 0.000031 3.100000e-05 3.1e-05 0x1.040bfe3b03e21p-15
NSLog(@"db2 = %f %e %g %a", db2, db2, db2, db2);
// db3 = 0.500000 5.000000e-01 0.5 0x1p-1
NSLog(@"db3 = %f %e %g %a", db3, db3, db3, db3);
long double lb = 3.1e-51;
// lb = 0.000000, 3.100000e-51, 3.1e-51
NSLog(@"lb = %Lf, %Le, %Lg", lb, lb, lb);
id obj = nil;
// obj = 0x1.fffd7effd2ep-1028( ), 0x0
NSLog(@"obj = %a, %p", obj, obj);
// obj = 0x1.fffd7effd2ep-1028( )
NSLog(@"obj = %a", obj);
[pool drain];
return 0;
}