NSLog(@"%llu\n\n", ULONG_LONG_MAX); NSDecimalNumber *decimal = [NSDecimalNumber decimalNumberWithString:@"154550038129946620"]; NSLog(@"%@", decimal); NSLog(@"%llu\n\n", [decimal unsignedLongLongValue]); decimal = [NSDecimalNumber decimalNumberWithString:@"154550038129946628"]; NSLog(@"%@", decimal); NSLog(@"%llu", [decimal unsignedLongLongValue]);
Both values ββare less than ULONG_LONG_MAX. But, what we see in the output:
2012-01-05 17:41:55.879 test[1276:207] 18446744073709551615 2012-01-05 17:41:55.969 test[1276:207] 154550038129946620 2012-01-05 17:41:56.095 test[1276:207] 154550038129946624 2012-01-05 17:41:56.096 test[1276:207] 154550038129946628 2012-01-05 17:41:56.096 test[1276:207] 154550038129946624
What am I doing wrong? I do not know how to explain this behavior.
source share