NSDecimalNumber学习记录
来源:互联网 发布:淘宝如何找客户 编辑:程序博客网 时间:2024/06/03 12:06
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).
Creating a Decimal Number
++ decimalNumberWithDecimal:
快速创建一个十进制,参数是一个NSDecimal结构体
+ decimalNumberWithMantissa:exponent:isNegative:
用一个u long long定点数,一个short指数,一个bool正负
+ decimalNumberWithString:
自己看文档
+ decimalNumberWithString:locale:
Initializing a Decimal Number
- initWithDecimal:
- initWithMantissa:exponent:isNegative:
- initWithString:.
- initWithString:locale:
Performing Arithmetic(算法)
- decimalNumberByAdding:
- decimalNumberBySubtracting: (减法)
- decimalNumberByMultiplyingBy:
- decimalNumberByDividingBy:
- decimalNumberByRaisingToPower:(幂)
- decimalNumberByMultiplyingByPowerOf10:
Multiplies the receiver by 10^power and returns the product, a newly created NSDecimalNumber object.
余下的方法是上面的方法附带一个withBehavior:参数
Rounding Off 四舍五入
- decimalNumberByRoundingAccordingToBehavior:
Accessing the Value
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学习记录
- OC : NSDecimalNumber
- NSDecimalNumber使用
- NSDecimalNumber NSNumber 区别 使用方法
- iOS NSDecimalNumber详解
- iOS---Foundation(NSDecimalNumber.h)
- iOS NSDecimalNumber--货币计算
- iOS NSDecimalNumber的基本知识
- 转载{NSDecimalNumber.h}
- NSDecimalNumber的使用
- ‘NSDecimalNumber--十进制数’使用方法
- NSDecimalNumber的用法
- iOS NSDecimalNumber 货币计算 四舍五入
- iOS 笔记 精确计算 NSDecimalNumber
- iOS NSDecimalNumber 货币计算 四舍五入
- NSDecimalNumber的介绍和使用!
- --学习记录
- 学习记录
- bzoj 1497: [NOI2006]最大获利-----------算法模板[最大权闭合子图]&省选计划系列
- ICE入门之hello world
- Tomcat server.xml配置详解(转载地址)
- indexerror: too many indices for array
- ionic添加cordova插件-SMS
- NSDecimalNumber学习记录
- [Mapbox GL]创建悬停效果
- 股票入门基础知识17:计算每股收益(EPS):衡量股票真实价格
- YOLO源码详解(一)-训练
- npm install Refusing to install xxx as a dependency of itself
- eclipse集成SVN插件
- 快速恢复被刚刚不小心被修改数据的表
- python脚本用sqoop把mysql数据导入hive数据仓库中
- 取汇率的程序