API  0.9.6
 All Classes Files Functions Variables Macros Groups Pages
CPDecimalNumber.j
Go to the documentation of this file.
1 /*
2  * CPDecimalNumber.j
3  * Foundation
4  *
5  * Created by Stephen Paul Ierodiaconou
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 
23 // The default global behavior class, created lazily
25 
33 {
34  CPRoundingMode _roundingMode;
35  short _scale;
36  BOOL _raiseOnExactness;
37  BOOL _raiseOnOverflow;
38  BOOL _raiseOnUnderflow;
39  BOOL _raiseOnDivideByZero;
40 }
41 
42 // initializers
49 - (id)init
50 {
51  return [self initWithRoundingMode:CPRoundPlain
52  scale:0
54  raiseOnOverflow:YES
57 }
58 
80 - (id)initWithRoundingMode:(CPRoundingMode)roundingMode scale:(short)scale raiseOnExactness:(BOOL)exact raiseOnOverflow:(BOOL)overflow raiseOnUnderflow:(BOOL)underflow raiseOnDivideByZero:(BOOL)divideByZero
81 {
82  if (self = [super init])
83  {
84  _roundingMode = roundingMode;
85  _scale = scale;
86  _raiseOnExactness = exact;
87  _raiseOnOverflow = overflow;
88  _raiseOnUnderflow = underflow;
89  _raiseOnDivideByZero = divideByZero;
90  }
91 
92  return self;
93 }
94 
95 // class methods
101 + (id)decimalNumberHandlerWithRoundingMode:(CPRoundingMode)roundingMode scale:(short)scale raiseOnExactness:(BOOL)exact raiseOnOverflow:(BOOL)overflow raiseOnUnderflow:(BOOL)underflow raiseOnDivideByZero:(BOOL)divideByZero
102 {
103  return [[self alloc] initWithRoundingMode:roundingMode
104  scale:scale
105  raiseOnExactness:exact
106  raiseOnOverflow:overflow
107  raiseOnUnderflow:underflow
108  raiseOnDivideByZero:divideByZero];
109 }
110 
117 + (id)defaultDecimalNumberHandler
118 {
119  if (!CPDefaultDcmHandler)
121  return CPDefaultDcmHandler;
122 }
123 
124 @end
125 
126 // CPDecimalNumberBehaviors protocol
128 
134 - (CPRoundingMode)roundingMode
135 {
136  return _roundingMode;
137 }
138 
143 - (short)scale
144 {
145  return _scale;
146 }
147 
166 - (CPDecimalNumber)exceptionDuringOperation:(SEL)operation error:(CPCalculationError)error leftOperand:(CPDecimalNumber)leftOperand rightOperand:(CPDecimalNumber)rightOperand
167 {
168  switch (error)
169  {
170  case CPCalculationNoError: break;
171  case CPCalculationOverflow: if (_raiseOnOverflow)
172  [CPException raise:CPDecimalNumberOverflowException reason:("A CPDecimalNumber overflow has occurred. (Left operand= '" + [leftOperand descriptionWithLocale:nil] + "' Right operand= '" + [rightOperand descriptionWithLocale:nil] + "' Selector= '" + operation + "')") ];
173  else
174  return [CPDecimalNumber notANumber];
175  break;
176  case CPCalculationUnderflow: if (_raiseOnUnderflow)
177  [CPException raise:CPDecimalNumberUnderflowException reason:("A CPDecimalNumber underflow has occurred. (Left operand= '" + [leftOperand descriptionWithLocale:nil] + "' Right operand= '" + [rightOperand descriptionWithLocale:nil] + "' Selector= '" + operation + "')") ];
178  else
179  return [CPDecimalNumber notANumber];
180  break;
181  case CPCalculationLossOfPrecision: if (_raiseOnExactness)
182  [CPException raise:CPDecimalNumberExactnessException reason:("A CPDecimalNumber has been rounded off during a calculation. (Left operand= '" + [leftOperand descriptionWithLocale:nil] + "' Right operand= '" + [rightOperand descriptionWithLocale:nil] + "' Selector= '" + operation + "')") ];
183  break;
184  case CPCalculationDivideByZero: if (_raiseOnDivideByZero)
185  [CPException raise:CPDecimalNumberDivideByZeroException reason:("A CPDecimalNumber divide by zero has occurred. (Left operand= '" + [leftOperand descriptionWithLocale:nil] + "' Right operand= '" + [rightOperand descriptionWithLocale:nil] + "' Selector= '" + operation + "')") ];
186  else
187  return [CPDecimalNumber notANumber]; // Div by zero returns NaN
188  break;
189  default: [CPException raise:CPInvalidArgumentException reason:("An unknown CPDecimalNumber error has occurred. (Left operand= '" + [leftOperand descriptionWithLocale:nil] + "' Right operand= '" + [rightOperand descriptionWithLocale:nil] + "' Selector= '" + operation + "')") ];
190  }
191 
192  return nil;
193 }
194 
195 @end
196 
197 // CPCoding category
198 var CPDecimalNumberHandlerRoundingModeKey = @"CPDecimalNumberHandlerRoundingModeKey",
199  CPDecimalNumberHandlerScaleKey = @"CPDecimalNumberHandlerScaleKey",
200  CPDecimalNumberHandlerRaiseOnExactKey = @"CPDecimalNumberHandlerRaiseOnExactKey",
201  CPDecimalNumberHandlerRaiseOnOverflowKey = @"CPDecimalNumberHandlerRaiseOnOverflowKey",
202  CPDecimalNumberHandlerRaiseOnUnderflowKey = @"CPDecimalNumberHandlerRaiseOnUnderflowKey",
203  CPDecimalNumberHandlerDivideByZeroKey = @"CPDecimalNumberHandlerDivideByZeroKey";
204 
206 
211 - (id)initWithCoder:(CPCoder)aCoder
212 {
213  if (self)
214  {
215  [self initWithRoundingMode:[aCoder decodeIntForKey:CPDecimalNumberHandlerRoundingModeKey]
216  scale:[aCoder decodeIntForKey:CPDecimalNumberHandlerScaleKey]
217  raiseOnExactness:[aCoder decodeBoolForKey:CPDecimalNumberHandlerRaiseOnExactKey]
218  raiseOnOverflow:[aCoder decodeBoolForKey:CPDecimalNumberHandlerRaiseOnOverflowKey]
219  raiseOnUnderflow:[aCoder decodeBoolForKey:CPDecimalNumberHandlerRaiseOnUnderflowKey]
220  raiseOnDivideByZero:[aCoder decodeBoolForKey:CPDecimalNumberHandlerDivideByZeroKey]];
221  }
222 
223  return self;
224 }
225 
230 - (void)encodeWithCoder:(CPCoder)aCoder
231 {
232  [aCoder encodeInt:[self roundingMode] forKey:CPDecimalNumberHandlerRoundingModeKey];
233  [aCoder encodeInt:[self scale] forKey:CPDecimalNumberHandlerScaleKey];
234  [aCoder encodeBool:_raiseOnExactness forKey:CPDecimalNumberHandlerRaiseOnExactKey];
235  [aCoder encodeBool:_raiseOnOverflow forKey:CPDecimalNumberHandlerRaiseOnOverflowKey];
236  [aCoder encodeBool:_raiseOnUnderflow forKey:CPDecimalNumberHandlerRaiseOnUnderflowKey];
237  [aCoder encodeBool:_raiseOnDivideByZero forKey:CPDecimalNumberHandlerDivideByZeroKey];
238 }
239 
240 @end
241 
289 @implementation CPDecimalNumber : CPNumber
290 {
291  CPDecimal _data;
292 }
293 
300 + (id)alloc
301 {
302  // overriding alloc means CPDecimalNumbers are not toll free bridged
303  return class_createInstance(self);
304 }
305 
306 // initializers
311 - (id)init
312 {
313  return [self initWithDecimal:CPDecimalMakeNaN()];
314 }
315 
321 - (id)initWithDecimal:(CPDecimal)dcm
322 {
323  if (self = [super init])
324  _data = CPDecimalCopy(dcm);
325 
326  return self;
327 }
328 
341 - (id)initWithMantissa:(unsigned long long)mantissa exponent:(short)exponent isNegative:(BOOL)flag
342 {
343  if (self = [self init])
344  {
345  if (flag)
346  mantissa *= -1;
347 
348  _data = CPDecimalMakeWithParts(mantissa, exponent);
349  }
350 
351  return self;
352 }
353 
361 - (id)initWithString:(CPString)numberValue
362 {
363  return [self initWithString:numberValue locale:nil];
364 }
365 
375 - (id)initWithString:(CPString)numberValue locale:(CPDictionary)locale
376 {
377  if (self = [self init])
378  {
379  _data = CPDecimalMakeWithString(numberValue, locale);
380  }
381 
382  return self;
383 }
384 
385 // class methods
391 + (CPDecimalNumber)decimalNumberWithDecimal:(CPDecimal)dcm
392 {
393  return [[self alloc] initWithDecimal:dcm];
394 }
395 
404 + (CPDecimalNumber)decimalNumberWithMantissa:(unsigned long long)mantissa exponent:(short)exponent isNegative:(BOOL)flag
405 {
406  return [[self alloc] initWithMantissa:mantissa exponent:exponent isNegative:flag];
407 }
408 
416 + (CPDecimalNumber)decimalNumberWithString:(CPString)numberValue
417 {
418  return [[self alloc] initWithString:numberValue];
419 }
420 
430 + (CPDecimalNumber)decimalNumberWithString:(CPString)numberValue locale:(CPDictionary)locale
431 {
432  return [[self alloc] initWithString:numberValue locale:locale];
433 }
434 
439 + (id)defaultBehavior
440 {
442 }
443 
449 + (void)setDefaultBehavior:(id <CPDecimalNumberBehaviors>)behavior
450 {
451  CPDefaultDcmHandler = behavior;
452 }
453 
460 + (CPDecimalNumber)maximumDecimalNumber
461 {
462  return [[self alloc] initWithDecimal:_CPDecimalMakeMaximum()];
463 }
464 
471 + (CPDecimalNumber)minimumDecimalNumber
472 {
473  return [[self alloc] initWithDecimal:_CPDecimalMakeMinimum()];
474 }
475 
480 + (CPDecimalNumber)notANumber
481 {
482  return [[self alloc] initWithDecimal:CPDecimalMakeNaN()];
483 }
484 
490 {
491  return [[self alloc] initWithDecimal:CPDecimalMakeZero()];
492 }
493 
499 {
500  return [[self alloc] initWithDecimal:CPDecimalMakeOne()];
501 }
502 
503 // instance methods
511 - (CPDecimalNumber)decimalNumberByAdding:(CPDecimalNumber)decimalNumber
512 {
514 }
515 
524 - (CPDecimalNumber)decimalNumberByAdding:(CPDecimalNumber)decimalNumber withBehavior:(id <CPDecimalNumberBehaviors>)behavior
525 {
526  var result = CPDecimalMakeZero(),
527  error = CPDecimalAdd(result, [self decimalValue], [decimalNumber decimalValue], [behavior roundingMode]);
528 
529  if (error > CPCalculationNoError)
530  {
531  var res = [behavior exceptionDuringOperation:_cmd error:error leftOperand:self rightOperand:decimalNumber];
532  if (res != nil)
533  return res;
534  }
536 }
537 
546 - (CPDecimalNumber)decimalNumberBySubtracting:(CPDecimalNumber)decimalNumber
547 {
549 }
550 
560 - (CPDecimalNumber)decimalNumberBySubtracting:(CPDecimalNumber)decimalNumber withBehavior:(id <CPDecimalNumberBehaviors>)behavior
561 {
562  var result = CPDecimalMakeZero(),
563  error = CPDecimalSubtract(result, [self decimalValue], [decimalNumber decimalValue], [behavior roundingMode]);
564 
565  if (error > CPCalculationNoError)
566  {
567  var res = [behavior exceptionDuringOperation:_cmd error:error leftOperand:self rightOperand:decimalNumber];
568  if (res != nil)
569  return res;
570  }
572 }
573 
582 - (CPDecimalNumber)decimalNumberByDividingBy:(CPDecimalNumber)decimalNumber
583 {
585 }
586 
596 - (CPDecimalNumber)decimalNumberByDividingBy:(CPDecimalNumber)decimalNumber withBehavior:(id <CPDecimalNumberBehaviors>)behavior
597 {
598  var result = CPDecimalMakeZero(),
599  error = CPDecimalDivide(result, [self decimalValue], [decimalNumber decimalValue], [behavior roundingMode]);
600 
601  if (error > CPCalculationNoError)
602  {
603  var res = [behavior exceptionDuringOperation:_cmd error:error leftOperand:self rightOperand:decimalNumber];
604  if (res != nil)
605  return res;
606  }
608 }
609 
618 - (CPDecimalNumber)decimalNumberByMultiplyingBy:(CPDecimalNumber)decimalNumber
619 {
621 }
622 
632 - (CPDecimalNumber)decimalNumberByMultiplyingBy:(CPDecimalNumber)decimalNumber withBehavior:(id <CPDecimalNumberBehaviors>)behavior
633 {
634  var result = CPDecimalMakeZero(),
635  error = CPDecimalMultiply(result, [self decimalValue], [decimalNumber decimalValue], [behavior roundingMode]);
636 
637  if (error > CPCalculationNoError)
638  {
639  var res = [behavior exceptionDuringOperation:_cmd error:error leftOperand:self rightOperand:decimalNumber];
640  if (res != nil)
641  return res;
642  }
644 }
645 
654 - (CPDecimalNumber)decimalNumberByMultiplyingByPowerOf10:(short)power
655 {
657 }
658 
668 - (CPDecimalNumber)decimalNumberByMultiplyingByPowerOf10:(short)power withBehavior:(id <CPDecimalNumberBehaviors>)behavior
669 {
670  var result = CPDecimalMakeZero(),
671  error = CPDecimalMultiplyByPowerOf10(result, [self decimalValue], power, [behavior roundingMode]);
672 
673  if (error > CPCalculationNoError)
674  {
675  var res = [behavior exceptionDuringOperation:_cmd error:error leftOperand:self rightOperand:[CPDecimalNumber decimalNumberWithString:power.toString()]];
676  if (res != nil)
677  return res;
678  }
680 }
681 
690 - (CPDecimalNumber)decimalNumberByRaisingToPower:(unsigned)power
691 {
693 }
694 
704 - (CPDecimalNumber)decimalNumberByRaisingToPower:(unsigned)power withBehavior:(id <CPDecimalNumberBehaviors>)behavior
705 {
706  if (power < 0)
707  return [behavior exceptionDuringOperation:_cmd error:-1 leftOperand:self rightOperand:[CPDecimalNumber decimalNumberWithString:power.toString()]];
708 
709  var result = CPDecimalMakeZero(),
710  error = CPDecimalPower(result, [self decimalValue], power, [behavior roundingMode]);
711 
712  if (error > CPCalculationNoError)
713  {
714  var res = [behavior exceptionDuringOperation:_cmd error:error leftOperand:self rightOperand:[CPDecimalNumber decimalNumberWithString:power.toString()]];
715  if (res != nil)
716  return res;
717  }
719 }
720 
728 - (CPDecimalNumber)decimalNumberByRoundingAccordingToBehavior:(id <CPDecimalNumberBehaviors>)behavior
729 {
730  var result = CPDecimalMakeZero();
731 
732  CPDecimalRound(result, [self decimalValue], [behavior scale], [behavior roundingMode]);
733 
735 }
736 
744 - (CPComparisonResult)compare:(CPNumber)aNumber
745 {
746  // aNumber type is checked to convert if appropriate
747  if (![aNumber isKindOfClass:[CPDecimalNumber class]])
748  aNumber = [CPDecimalNumber decimalNumberWithString:aNumber.toString()];
749  return CPDecimalCompare([self decimalValue], [aNumber decimalValue]);
750 }
751 
756 - (CPString)objCType
757 {
758  return @"d";
759 }
760 
765 - (CPString)description
766 {
767  return [self descriptionWithLocale:nil]
768 }
769 
776 - (CPString)descriptionWithLocale:(CPDictionary)locale
777 {
778  return CPDecimalString(_data, locale);
779 }
780 
785 - (CPString)stringValue
786 {
787  return [self description];
788 }
789 
795 - (CPDecimal)decimalValue
796 {
797  return CPDecimalCopy(_data);
798 }
799 
800 // Type Conversion Methods
805 - (double)doubleValue
806 {
807  // FIXME: locale support / bounds check?
808  return parseFloat([self stringValue]);
809 }
810 
815 - (BOOL)boolValue
816 {
817  return (CPDecimalIsZero(_data))?NO:YES;
818 }
819 
824 - (char)charValue
825 {
826  // FIXME: locale support / bounds check?
827  return parseInt([self stringValue]);
828 }
829 
834 - (float)floatValue
835 {
836  // FIXME: locale support / bounds check?
837  return parseFloat([self stringValue]);
838 }
839 
844 - (int)intValue
845 {
846  // FIXME: locale support / bounds check?
847  return parseInt([self stringValue]);
848 }
849 
854 - (long long)longLongValue
855 {
856  // FIXME: locale support / bounds check?
857  return parseInt([self stringValue]);
858 }
859 
864 - (long)longValue
865 {
866  // FIXME: locale support / bounds check?
867  return parseInt([self stringValue]);
868 }
869 
874 - (short)shortValue
875 {
876  // FIXME: locale support / bounds check?
877  return parseInt([self stringValue]);
878 }
879 
884 - (unsigned char)unsignedCharValue
885 {
886  // FIXME: locale support / bounds check?
887  return parseInt([self stringValue]);
888 }
889 
894 - (unsigned int)unsignedIntValue
895 {
896  // FIXME: locale support / bounds check?
897  return parseInt([self stringValue]);
898 }
899 
904 - (unsigned long)unsignedLongValue
905 {
906  // FIXME: locale support / bounds check?
907  return parseInt([self stringValue]);
908 }
909 
914 - (unsigned short)unsignedShortValue
915 {
916  // FIXME: locale support / bounds check?
917  return parseInt([self stringValue]);
918 }
919 
920 // CPNumber inherited methods
927 - (BOOL)isEqualToNumber:(CPNumber)aNumber
928 {
929  return (CPDecimalCompare(CPDecimalMakeWithString(aNumber.toString(),nil), _data) == CPOrderedSame)?YES:NO;
930 }
931 
937 + (id)numberWithBool:(BOOL)aBoolean
938 {
939  return [[self alloc] initWithBool:aBoolean];
940 }
941 
947 + (id)numberWithChar:(char)aChar
948 {
949  return [[self alloc] initWithChar:aChar];
950 }
951 
957 + (id)numberWithDouble:(double)aDouble
958 {
959  return [[self alloc] initWithDouble:aDouble];
960 }
961 
967 + (id)numberWithFloat:(float)aFloat
968 {
969  return [[self alloc] initWithFloat:aFloat];
970 }
971 
977 + (id)numberWithInt:(int)anInt
978 {
979  return [[self alloc] initWithInt:anInt];
980 }
981 
987 + (id)numberWithLong:(long)aLong
988 {
989  return [[self alloc] initWithLong:aLong];
990 }
991 
997 + (id)numberWithLongLong:(long long)aLongLong
998 {
999  return [[self alloc] initWithLongLong:aLongLong];
1000 }
1001 
1007 + (id)numberWithShort:(short)aShort
1008 {
1009  return [[self alloc] initWithShort:aShort];
1010 }
1011 
1017 + (id)numberWithUnsignedChar:(unsigned char)aChar
1018 {
1019  return [[self alloc] initWithUnsignedChar:aChar];
1020 }
1021 
1027 + (id)numberWithUnsignedInt:(unsigned)anUnsignedInt
1028 {
1029  return [[self alloc] initWithUnsignedInt:anUnsignedInt];
1030 }
1031 
1037 + (id)numberWithUnsignedLong:(unsigned long)anUnsignedLong
1038 {
1039  return [[self alloc] initWithUnsignedLong:anUnsignedLong];
1040 }
1041 
1047 + (id)numberWithUnsignedLongLong:(unsigned long)anUnsignedLongLong
1048 {
1049  return [[self alloc] initWithUnsignedLongLong:anUnsignedLongLong];
1050 }
1051 
1057 + (id)numberWithUnsignedShort:(unsigned short)anUnsignedShort
1058 {
1059  return [[self alloc] initWithUnsignedShort:anUnsignedShort];
1060 }
1061 
1067 - (id)initWithBool:(BOOL)value
1068 {
1069  if (self = [self init])
1070  _data = CPDecimalMakeWithParts((value)?1:0, 0);
1071  return self;
1072 }
1073 
1079 - (id)initWithChar:(char)value
1080 {
1081  return [self _initWithJSNumber:value];
1082 }
1083 
1089 - (id)initWithDouble:(double)value
1090 {
1091  return [self _initWithJSNumber:value];
1092 }
1093 
1099 - (id)initWithFloat:(float)value
1100 {
1101  return [self _initWithJSNumber:value];
1102 }
1103 
1109 - (id)initWithInt:(int)value
1110 {
1111  return [self _initWithJSNumber:value];
1112 }
1113 
1119 - (id)initWithLong:(long)value
1120 {
1121  return [self _initWithJSNumber:value];
1122 }
1123 
1129 - (id)initWithLongLong:(long long)value
1130 {
1131  return [self _initWithJSNumber:value];
1132 }
1133 
1139 - (id)initWithShort:(short)value
1140 {
1141  return [self _initWithJSNumber:value];
1142 }
1143 
1149 - (id)initWithUnsignedChar:(unsigned char)value
1150 {
1151  return [self _initWithJSNumber:value];
1152 }
1153 
1159 - (id)initWithUnsignedInt:(unsigned)value
1160 {
1161  return [self _initWithJSNumber:value];
1162 }
1163 
1169 - (id)initWithUnsignedLong:(unsigned long)value
1170 {
1171  return [self _initWithJSNumber:value];
1172 }
1173 
1179 - (id)initWithUnsignedLongLong:(unsigned long long)value
1180 {
1181  return [self _initWithJSNumber:value];
1182 }
1183 
1189 - (id)initWithUnsignedShort:(unsigned short)value
1190 {
1191  return [self _initWithJSNumber:value];
1192 }
1193 
1194 - (id)_initWithJSNumber:value
1195 {
1196  if (self = [self init])
1197  _data = CPDecimalMakeWithString(value.toString(), nil);
1198  return self;
1199 }
1200 
1201 @end
1202 
1203 // CPCoding category
1204 var CPDecimalNumberDecimalExponent = @"CPDecimalNumberDecimalExponent",
1205  CPDecimalNumberDecimalIsNegative = @"CPDecimalNumberDecimalIsNegative",
1206  CPDecimalNumberDecimalIsCompact = @"CPDecimalNumberDecimalIsCompact",
1207  CPDecimalNumberDecimalIsNaN = @"CPDecimalNumberDecimalIsNaN",
1208  CPDecimalNumberDecimalMantissa = @"CPDecimalNumberDecimalMantissa";
1209 
1211 
1216 - (id)initWithCoder:(CPCoder)aCoder
1217 {
1218  if (self)
1219  {
1220  var dcm = CPDecimalMakeZero();
1221  dcm._exponent = [aCoder decodeIntForKey:CPDecimalNumberDecimalExponent];
1222  dcm._isNegative = [aCoder decodeBoolForKey:CPDecimalNumberDecimalIsNegative];
1223  dcm._isCompact = [aCoder decodeBoolForKey:CPDecimalNumberDecimalIsCompact];
1224  dcm._isNaN = [aCoder decodeBoolForKey:CPDecimalNumberDecimalIsNaN];
1225  dcm._mantissa = [aCoder decodeObjectForKey:CPDecimalNumberDecimalMantissa];
1226  [self initWithDecimal:dcm];
1227  }
1228 
1229  return self;
1230 }
1231 
1236 - (void)encodeWithCoder:(CPCoder)aCoder
1237 {
1238  [aCoder encodeInt:_data._exponent forKey:CPDecimalNumberDecimalExponent];
1239  [aCoder encodeBool:_data._isNegative forKey:CPDecimalNumberDecimalIsNegative];
1240  [aCoder encodeBool:_data._isCompact forKey:CPDecimalNumberDecimalIsCompact];
1241  [aCoder encodeBool:_data._isNaN forKey:CPDecimalNumberDecimalIsNaN];
1242  [aCoder encodeObject:_data._mantissa forKey:CPDecimalNumberDecimalMantissa];
1243 }
1244 
1245 @end