+2006-12-02 Helge Hess <helge.hess@opengroupware.org>
+
+ * EOKeyValueCoding.m: added NSDecimalNumber implementation for
+ -computeSumForKey: (TBD: implementations for the other methods)
+ (v4.5.69)
+
2006-09-30 Helge Hess <helge.hess@opengroupware.org>
* EOKeyGlobalID.m: print a warning if a key-gid is created with a nil
- (id)computeSumForKey:(NSString *)_key {
unsigned i, cc = [self count];
id (*objAtIdx)(id, SEL, unsigned int);
+#if LIB_FOUNDATION_LIBRARY
double sum;
if (cc == 0) return [NSNumber numberWithDouble:0.0];
sum += [o doubleValue];
}
return [NSNumber numberWithDouble:sum];
+#else
+ NSDecimalNumber *n;
+
+ n = [NSDecimalNumber zero]
+ if (cc == 0) return n;
+
+ objAtIdx = (void*)[self methodForSelector:@selector(objectAtIndex:)];
+
+ for (i = 0, sum = 0.0; i < cc; i++) {
+ register id o;
+
+ o = objAtIdx(self, @selector(objectAtIndex:), i);
+
+ if ([o isKindOfClass:[NSDecimalNumber class]])
+ n = [n decimalNumberByAdding:o];
+ else {
+ n = [n decimalNumberByAdding:
+ [NSDecimalNumber numberWithDouble:[o doubleValue]]];
+ }
+ }
+ return n;
+#endif
}
- (id)computeAvgForKey:(NSString *)_key {
unsigned i, cc = [self count];
id (*objAtIdx)(id, SEL, unsigned int);
double min;
-
+
if (cc == 0) return nil;
objAtIdx = (void *)[self methodForSelector:@selector(objectAtIndex:)];
-
+
min = [objAtIdx(self, @selector(objectAtIndex:), 0) doubleValue];
for (i = 1; i < cc; i++) {
register double ov;