我正在寻找一种有效的方法来保存缓冲区NSDecimalNumber
中的其他数据。NSData
我还没有找到直接从NSDecimalNumber
. 但是,很容易将其转换为:
NSDecimal value = [theDecimalNumber decimalValue];
NSDecimal
并且在内存中传输(20字节)并不困难。
但是,我的问题是:和NSDecimalNumber
值NSDecimal
是否完全相同?
因为他们的声明有一些不同(ExternalRefCount
?):
@interface NSDecimalNumber : NSNumber {
@private
signed int _exponent:8;
unsigned int _length:4;
unsigned int _isNegative:1;
unsigned int _isCompact:1;
unsigned int _reserved:1;
unsigned int _hasExternalRefCount:1;
unsigned int _refs:16;
unsigned short _mantissa[0]; /* GCC */
}
typedef struct {
signed int _exponent:8;
unsigned int _length:4; // length == 0 && isNegative -> NaN
unsigned int _isNegative:1;
unsigned int _isCompact:1;
unsigned int _reserved:18;
unsigned short _mantissa[NSDecimalMaxSize];
} NSDecimal;
是否可以在这两种类型之间执行多次传输,而不会损失任何精度?