NSDecimalNumber是NSNumber的子類,不可變,提供一個面向對象的方式來做十進制運算.是一個wrapper,我猜是有相應的CF函數的.一個實例可以表示任何數字在這個范圍內(mantissa x 10^exponent)
> mantissa 定點局部 exponent 指數
定點局部是一個十進制數,最高38位;指數是一個整數,從-128到127.
IOS 2.0+
macOS 10.0+
tvOS 9.0+
watchOS 2.0+
Important
The Swift overlay to the Foundation framework provides the Decimal
structure, which bridges to the NSDecimalNumber class. The Decimal
value type offers the same functionality as the NSDecimalNumber
reference type, and the two can be used interchangeably in Swift code
that interacts with Objective-C APIs. This behavior is similar to how
Swift bridges standard string, numeric, and collection types to their
corresponding Foundation classes.
For more information about value types, see Classes and Structures in
The Swift Programming Language (Swift 3.0.1) and Working with Cocoa
Frameworks in Using Swift with Cocoa and Objective-C (Swift 3.0.1).
++ decimalNumberWithDecimal:
疾速創立一個十進制,參數是一個NSDecimal構造體
+ decimalNumberWithMantissa:exponent:isNegative:
用一個u long long定點數,一個short指數,一個bool正負
+ decimalNumberWithString:
自己看文檔
+ decimalNumberWithString:locale:
decimalValue
The decimal number’s value, expressed as an NSDecimal structure.
doubleValue
The decimal number’s closest approximate double value.
- descriptionWithLocale:
Comparing Decimal Numbers
- compare:
比擬
【NSDecimalNumber學習記載】的相關資料介紹到這裡,希望對您有所幫助! 提示:不會對讀者因本文所帶來的任何損失負責。如果您支持就請把本站添加至收藏夾哦!