1

I am using NSExpression to get the sum of some values from core data. The attribute type is set to int64 and the values are in hundreds or thousands of billions. The weird problem im facing is that the sum value is different from the real sum only in a few thousands. Here is the snippet code i use along side my fetch request:

NSExpressionDescription *qtyDescription = [[NSExpressionDescription alloc] init];
qtyDescription.name = @"price";
qtyDescription.expression = [NSExpression expressionForKeyPath:@"@sum.price"];
qtyDescription.expressionResultType = NSInteger64AttributeType;
Rashid
  • 762
  • 1
  • 9
  • 30
  • give a sample of calculation of mismatch – Jamil Sep 20 '15 at 18:19
  • Is `@sum:price` really a key path? – Mundi Sep 20 '15 at 22:21
  • @Mundi yes it is, the attribute is price – Rashid Sep 21 '15 at 05:11
  • @jamil65able its summing like 400 large numbers. one thing that i noticed is that the difference is much smaller than the smallest number in the core data. the minimum is something between a few millions and the difference is always in range of a few thousands. – Rashid Sep 21 '15 at 05:13
  • @jim I have never seen a key path with a semicolon. `:`. – Mundi Sep 21 '15 at 07:30
  • @Mundi I edited my question. I used . in my original code. thanks for noticing – Rashid Sep 21 '15 at 07:36
  • You should expand your question and show the code you use to calculate the alternative result. You should give both concrete results in your question. If possible you should attach a link to a downloadable list of the numbers you are adding. – Mundi Sep 21 '15 at 18:40

0 Answers0