├── .gitignore ├── README.md ├── YWDecimalsCalculationDemo.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ ├── FishYu.xcuserdatad │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ │ ├── YWDecimalsCalculationDemo.xcscheme │ │ └── xcschememanagement.plist │ └── gaolailong.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── YWDecimalsCalculationDemo.xcscheme │ └── xcschememanagement.plist └── YWDecimalsCalculationDemo ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets └── AppIcon.appiconset │ └── Contents.json ├── Base.lproj ├── LaunchScreen.storyboard └── Main.storyboard ├── Info.plist ├── ViewController.h ├── ViewController.m ├── YWDecimalsCalculation ├── NSString+DecimalsCalculation.h └── NSString+DecimalsCalculation.m └── main.m /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | YWDecimalsCalculationDemo.xcodeproj/project.xcworkspace/xcuserdata/gaolailong.xcuserdatad/UserInterfaceState.xcuserstate 3 | 4 | *.xcuserstate 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | Usage 3 | === 4 | 5 | ``` 6 | // Rounding policies : 7 | // Original 8 | // value 1.2 1.21 1.25 1.35 1.27 9 | // Plain   1.2 1.2   1.3   1.4   1.3  四舍五入 10 | // Down     1.2 1.2   1.2   1.3   1.2 向下取正 11 | // Up       1.2 1.3   1.3   1.4   1.3 向上取正 12 | // Bankers 1.2 1.2   1.2   1.4   1.3 (特殊的四舍五入,碰到保留位数后一位的数字为5时,根据前一位的奇偶性决定。为偶时向下取正,为奇数时向上取正。如:1.25保留1为小数。5之前是2偶数向下取正1.2;1.35保留1位小数时。5之前为3奇数,向上取正1.4) 13 | 14 | ``` 15 | 16 | 新版本采用NSNumberFormatter格式化计算结果,直接通过scale设置最后计算结果的小数点位数,下面是部分计算例子: 17 | ps:开发可以通过设置RoudingMode和scale来设置计算结果的四舍五入的方式和保留小数的位数。 18 | ```objc 19 | // 10.4+2: 四舍五入不保留小数 20 | NSString *result = [@"10.4" yw_stringByAdding:@"2" withRoundingMode:NSRoundPlain scale:0]; // @"12" 21 | // 10.4-2:向下取值保留一位小数 22 | NSString *result = [@"10.4" yw_stringBySubtracting:@"2" withRoundingMode:NSRoundDown scale:1]; // @"8.4" 23 | // 10.4*2: 四舍五入,保留三位小数 24 | NSString *result = [@"10.4" yw_stringByMultiplyingBy:@"2" withRoundingMode:NSRoundPlain scale:3]; // @"20.800" 25 | // 10.4÷2:默认四舍五入,保留两位小数 26 | NSString *result = [@"10.4" yw_stringByDividingBy:@"2"]; // @"5.20" 27 | ``` 28 | 29 | 在使用过程中如果有任何疑问可以给我issue,如果觉得对你的问题的有所帮助话给个Star✨吧!!🙂 30 | 31 | -------------------------------------------------------------------------------- /YWDecimalsCalculationDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 662D9E881DD05BF9006B80DA /* NSString+DecimalsCalculation.m in Sources */ = {isa = PBXBuildFile; fileRef = 662D9E851DD05BF9006B80DA /* NSString+DecimalsCalculation.m */; }; 11 | 66F52CF81DCC3AA700FCCE15 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 66F52CF71DCC3AA700FCCE15 /* main.m */; }; 12 | 66F52CFB1DCC3AA700FCCE15 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 66F52CFA1DCC3AA700FCCE15 /* AppDelegate.m */; }; 13 | 66F52CFE1DCC3AA700FCCE15 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 66F52CFD1DCC3AA700FCCE15 /* ViewController.m */; }; 14 | 66F52D011DCC3AA700FCCE15 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 66F52CFF1DCC3AA700FCCE15 /* Main.storyboard */; }; 15 | 66F52D031DCC3AA700FCCE15 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 66F52D021DCC3AA700FCCE15 /* Assets.xcassets */; }; 16 | 66F52D061DCC3AA700FCCE15 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 66F52D041DCC3AA700FCCE15 /* LaunchScreen.storyboard */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXFileReference section */ 20 | 662D9E841DD05BF9006B80DA /* NSString+DecimalsCalculation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+DecimalsCalculation.h"; sourceTree = ""; }; 21 | 662D9E851DD05BF9006B80DA /* NSString+DecimalsCalculation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+DecimalsCalculation.m"; sourceTree = ""; }; 22 | 66F52CF31DCC3AA700FCCE15 /* YWDecimalsCalculationDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = YWDecimalsCalculationDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 23 | 66F52CF71DCC3AA700FCCE15 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 24 | 66F52CF91DCC3AA700FCCE15 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 25 | 66F52CFA1DCC3AA700FCCE15 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 26 | 66F52CFC1DCC3AA700FCCE15 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 27 | 66F52CFD1DCC3AA700FCCE15 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 28 | 66F52D001DCC3AA700FCCE15 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 29 | 66F52D021DCC3AA700FCCE15 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 30 | 66F52D051DCC3AA700FCCE15 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 31 | 66F52D071DCC3AA700FCCE15 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 32 | /* End PBXFileReference section */ 33 | 34 | /* Begin PBXFrameworksBuildPhase section */ 35 | 66F52CF01DCC3AA700FCCE15 /* Frameworks */ = { 36 | isa = PBXFrameworksBuildPhase; 37 | buildActionMask = 2147483647; 38 | files = ( 39 | ); 40 | runOnlyForDeploymentPostprocessing = 0; 41 | }; 42 | /* End PBXFrameworksBuildPhase section */ 43 | 44 | /* Begin PBXGroup section */ 45 | 662D9E831DD05BF9006B80DA /* YWDecimalsCalculation */ = { 46 | isa = PBXGroup; 47 | children = ( 48 | 662D9E841DD05BF9006B80DA /* NSString+DecimalsCalculation.h */, 49 | 662D9E851DD05BF9006B80DA /* NSString+DecimalsCalculation.m */, 50 | ); 51 | path = YWDecimalsCalculation; 52 | sourceTree = ""; 53 | }; 54 | 66F52CEA1DCC3AA700FCCE15 = { 55 | isa = PBXGroup; 56 | children = ( 57 | 66F52CF51DCC3AA700FCCE15 /* YWDecimalsCalculationDemo */, 58 | 66F52CF41DCC3AA700FCCE15 /* Products */, 59 | ); 60 | sourceTree = ""; 61 | }; 62 | 66F52CF41DCC3AA700FCCE15 /* Products */ = { 63 | isa = PBXGroup; 64 | children = ( 65 | 66F52CF31DCC3AA700FCCE15 /* YWDecimalsCalculationDemo.app */, 66 | ); 67 | name = Products; 68 | sourceTree = ""; 69 | }; 70 | 66F52CF51DCC3AA700FCCE15 /* YWDecimalsCalculationDemo */ = { 71 | isa = PBXGroup; 72 | children = ( 73 | 662D9E831DD05BF9006B80DA /* YWDecimalsCalculation */, 74 | 66F52CF91DCC3AA700FCCE15 /* AppDelegate.h */, 75 | 66F52CFA1DCC3AA700FCCE15 /* AppDelegate.m */, 76 | 66F52CFC1DCC3AA700FCCE15 /* ViewController.h */, 77 | 66F52CFD1DCC3AA700FCCE15 /* ViewController.m */, 78 | 66F52CFF1DCC3AA700FCCE15 /* Main.storyboard */, 79 | 66F52D021DCC3AA700FCCE15 /* Assets.xcassets */, 80 | 66F52D041DCC3AA700FCCE15 /* LaunchScreen.storyboard */, 81 | 66F52D071DCC3AA700FCCE15 /* Info.plist */, 82 | 66F52CF61DCC3AA700FCCE15 /* Supporting Files */, 83 | ); 84 | path = YWDecimalsCalculationDemo; 85 | sourceTree = ""; 86 | }; 87 | 66F52CF61DCC3AA700FCCE15 /* Supporting Files */ = { 88 | isa = PBXGroup; 89 | children = ( 90 | 66F52CF71DCC3AA700FCCE15 /* main.m */, 91 | ); 92 | name = "Supporting Files"; 93 | sourceTree = ""; 94 | }; 95 | /* End PBXGroup section */ 96 | 97 | /* Begin PBXNativeTarget section */ 98 | 66F52CF21DCC3AA700FCCE15 /* YWDecimalsCalculationDemo */ = { 99 | isa = PBXNativeTarget; 100 | buildConfigurationList = 66F52D0A1DCC3AA700FCCE15 /* Build configuration list for PBXNativeTarget "YWDecimalsCalculationDemo" */; 101 | buildPhases = ( 102 | 66F52CEF1DCC3AA700FCCE15 /* Sources */, 103 | 66F52CF01DCC3AA700FCCE15 /* Frameworks */, 104 | 66F52CF11DCC3AA700FCCE15 /* Resources */, 105 | ); 106 | buildRules = ( 107 | ); 108 | dependencies = ( 109 | ); 110 | name = YWDecimalsCalculationDemo; 111 | productName = YWDecimalsCalculationDemo; 112 | productReference = 66F52CF31DCC3AA700FCCE15 /* YWDecimalsCalculationDemo.app */; 113 | productType = "com.apple.product-type.application"; 114 | }; 115 | /* End PBXNativeTarget section */ 116 | 117 | /* Begin PBXProject section */ 118 | 66F52CEB1DCC3AA700FCCE15 /* Project object */ = { 119 | isa = PBXProject; 120 | attributes = { 121 | LastUpgradeCheck = 0900; 122 | ORGANIZATIONNAME = codeFisher; 123 | TargetAttributes = { 124 | 66F52CF21DCC3AA700FCCE15 = { 125 | CreatedOnToolsVersion = 8.0; 126 | ProvisioningStyle = Automatic; 127 | }; 128 | }; 129 | }; 130 | buildConfigurationList = 66F52CEE1DCC3AA700FCCE15 /* Build configuration list for PBXProject "YWDecimalsCalculationDemo" */; 131 | compatibilityVersion = "Xcode 3.2"; 132 | developmentRegion = English; 133 | hasScannedForEncodings = 0; 134 | knownRegions = ( 135 | en, 136 | Base, 137 | ); 138 | mainGroup = 66F52CEA1DCC3AA700FCCE15; 139 | productRefGroup = 66F52CF41DCC3AA700FCCE15 /* Products */; 140 | projectDirPath = ""; 141 | projectRoot = ""; 142 | targets = ( 143 | 66F52CF21DCC3AA700FCCE15 /* YWDecimalsCalculationDemo */, 144 | ); 145 | }; 146 | /* End PBXProject section */ 147 | 148 | /* Begin PBXResourcesBuildPhase section */ 149 | 66F52CF11DCC3AA700FCCE15 /* Resources */ = { 150 | isa = PBXResourcesBuildPhase; 151 | buildActionMask = 2147483647; 152 | files = ( 153 | 66F52D061DCC3AA700FCCE15 /* LaunchScreen.storyboard in Resources */, 154 | 66F52D031DCC3AA700FCCE15 /* Assets.xcassets in Resources */, 155 | 66F52D011DCC3AA700FCCE15 /* Main.storyboard in Resources */, 156 | ); 157 | runOnlyForDeploymentPostprocessing = 0; 158 | }; 159 | /* End PBXResourcesBuildPhase section */ 160 | 161 | /* Begin PBXSourcesBuildPhase section */ 162 | 66F52CEF1DCC3AA700FCCE15 /* Sources */ = { 163 | isa = PBXSourcesBuildPhase; 164 | buildActionMask = 2147483647; 165 | files = ( 166 | 66F52CFE1DCC3AA700FCCE15 /* ViewController.m in Sources */, 167 | 662D9E881DD05BF9006B80DA /* NSString+DecimalsCalculation.m in Sources */, 168 | 66F52CFB1DCC3AA700FCCE15 /* AppDelegate.m in Sources */, 169 | 66F52CF81DCC3AA700FCCE15 /* main.m in Sources */, 170 | ); 171 | runOnlyForDeploymentPostprocessing = 0; 172 | }; 173 | /* End PBXSourcesBuildPhase section */ 174 | 175 | /* Begin PBXVariantGroup section */ 176 | 66F52CFF1DCC3AA700FCCE15 /* Main.storyboard */ = { 177 | isa = PBXVariantGroup; 178 | children = ( 179 | 66F52D001DCC3AA700FCCE15 /* Base */, 180 | ); 181 | name = Main.storyboard; 182 | sourceTree = ""; 183 | }; 184 | 66F52D041DCC3AA700FCCE15 /* LaunchScreen.storyboard */ = { 185 | isa = PBXVariantGroup; 186 | children = ( 187 | 66F52D051DCC3AA700FCCE15 /* Base */, 188 | ); 189 | name = LaunchScreen.storyboard; 190 | sourceTree = ""; 191 | }; 192 | /* End PBXVariantGroup section */ 193 | 194 | /* Begin XCBuildConfiguration section */ 195 | 66F52D081DCC3AA700FCCE15 /* Debug */ = { 196 | isa = XCBuildConfiguration; 197 | buildSettings = { 198 | ALWAYS_SEARCH_USER_PATHS = NO; 199 | CLANG_ANALYZER_NONNULL = YES; 200 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 201 | CLANG_CXX_LIBRARY = "libc++"; 202 | CLANG_ENABLE_MODULES = YES; 203 | CLANG_ENABLE_OBJC_ARC = YES; 204 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 205 | CLANG_WARN_BOOL_CONVERSION = YES; 206 | CLANG_WARN_COMMA = YES; 207 | CLANG_WARN_CONSTANT_CONVERSION = YES; 208 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 209 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 210 | CLANG_WARN_EMPTY_BODY = YES; 211 | CLANG_WARN_ENUM_CONVERSION = YES; 212 | CLANG_WARN_INFINITE_RECURSION = YES; 213 | CLANG_WARN_INT_CONVERSION = YES; 214 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 215 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 216 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 217 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 218 | CLANG_WARN_STRICT_PROTOTYPES = YES; 219 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 220 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 221 | CLANG_WARN_UNREACHABLE_CODE = YES; 222 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 223 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 224 | COPY_PHASE_STRIP = NO; 225 | DEBUG_INFORMATION_FORMAT = dwarf; 226 | ENABLE_STRICT_OBJC_MSGSEND = YES; 227 | ENABLE_TESTABILITY = YES; 228 | GCC_C_LANGUAGE_STANDARD = gnu99; 229 | GCC_DYNAMIC_NO_PIC = NO; 230 | GCC_NO_COMMON_BLOCKS = YES; 231 | GCC_OPTIMIZATION_LEVEL = 0; 232 | GCC_PREPROCESSOR_DEFINITIONS = ( 233 | "DEBUG=1", 234 | "$(inherited)", 235 | ); 236 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 237 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 238 | GCC_WARN_UNDECLARED_SELECTOR = YES; 239 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 240 | GCC_WARN_UNUSED_FUNCTION = YES; 241 | GCC_WARN_UNUSED_VARIABLE = YES; 242 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 243 | MTL_ENABLE_DEBUG_INFO = YES; 244 | ONLY_ACTIVE_ARCH = YES; 245 | SDKROOT = iphoneos; 246 | }; 247 | name = Debug; 248 | }; 249 | 66F52D091DCC3AA700FCCE15 /* Release */ = { 250 | isa = XCBuildConfiguration; 251 | buildSettings = { 252 | ALWAYS_SEARCH_USER_PATHS = NO; 253 | CLANG_ANALYZER_NONNULL = YES; 254 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 255 | CLANG_CXX_LIBRARY = "libc++"; 256 | CLANG_ENABLE_MODULES = YES; 257 | CLANG_ENABLE_OBJC_ARC = YES; 258 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 259 | CLANG_WARN_BOOL_CONVERSION = YES; 260 | CLANG_WARN_COMMA = YES; 261 | CLANG_WARN_CONSTANT_CONVERSION = YES; 262 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 263 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 264 | CLANG_WARN_EMPTY_BODY = YES; 265 | CLANG_WARN_ENUM_CONVERSION = YES; 266 | CLANG_WARN_INFINITE_RECURSION = YES; 267 | CLANG_WARN_INT_CONVERSION = YES; 268 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 269 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 270 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 271 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 272 | CLANG_WARN_STRICT_PROTOTYPES = YES; 273 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 274 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 275 | CLANG_WARN_UNREACHABLE_CODE = YES; 276 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 277 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 278 | COPY_PHASE_STRIP = NO; 279 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 280 | ENABLE_NS_ASSERTIONS = NO; 281 | ENABLE_STRICT_OBJC_MSGSEND = YES; 282 | GCC_C_LANGUAGE_STANDARD = gnu99; 283 | GCC_NO_COMMON_BLOCKS = YES; 284 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 285 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 286 | GCC_WARN_UNDECLARED_SELECTOR = YES; 287 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 288 | GCC_WARN_UNUSED_FUNCTION = YES; 289 | GCC_WARN_UNUSED_VARIABLE = YES; 290 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 291 | MTL_ENABLE_DEBUG_INFO = NO; 292 | SDKROOT = iphoneos; 293 | VALIDATE_PRODUCT = YES; 294 | }; 295 | name = Release; 296 | }; 297 | 66F52D0B1DCC3AA700FCCE15 /* Debug */ = { 298 | isa = XCBuildConfiguration; 299 | buildSettings = { 300 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 301 | INFOPLIST_FILE = YWDecimalsCalculationDemo/Info.plist; 302 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 303 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 304 | PRODUCT_BUNDLE_IDENTIFIER = com.codeFisher.YWDecimalsCalculationDemo; 305 | PRODUCT_NAME = "$(TARGET_NAME)"; 306 | }; 307 | name = Debug; 308 | }; 309 | 66F52D0C1DCC3AA700FCCE15 /* Release */ = { 310 | isa = XCBuildConfiguration; 311 | buildSettings = { 312 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 313 | INFOPLIST_FILE = YWDecimalsCalculationDemo/Info.plist; 314 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 315 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 316 | PRODUCT_BUNDLE_IDENTIFIER = com.codeFisher.YWDecimalsCalculationDemo; 317 | PRODUCT_NAME = "$(TARGET_NAME)"; 318 | }; 319 | name = Release; 320 | }; 321 | /* End XCBuildConfiguration section */ 322 | 323 | /* Begin XCConfigurationList section */ 324 | 66F52CEE1DCC3AA700FCCE15 /* Build configuration list for PBXProject "YWDecimalsCalculationDemo" */ = { 325 | isa = XCConfigurationList; 326 | buildConfigurations = ( 327 | 66F52D081DCC3AA700FCCE15 /* Debug */, 328 | 66F52D091DCC3AA700FCCE15 /* Release */, 329 | ); 330 | defaultConfigurationIsVisible = 0; 331 | defaultConfigurationName = Release; 332 | }; 333 | 66F52D0A1DCC3AA700FCCE15 /* Build configuration list for PBXNativeTarget "YWDecimalsCalculationDemo" */ = { 334 | isa = XCConfigurationList; 335 | buildConfigurations = ( 336 | 66F52D0B1DCC3AA700FCCE15 /* Debug */, 337 | 66F52D0C1DCC3AA700FCCE15 /* Release */, 338 | ); 339 | defaultConfigurationIsVisible = 0; 340 | defaultConfigurationName = Release; 341 | }; 342 | /* End XCConfigurationList section */ 343 | }; 344 | rootObject = 66F52CEB1DCC3AA700FCCE15 /* Project object */; 345 | } 346 | -------------------------------------------------------------------------------- /YWDecimalsCalculationDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /YWDecimalsCalculationDemo.xcodeproj/xcuserdata/FishYu.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 20 | 21 | 22 | 24 | 36 | 37 | 38 | 40 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /YWDecimalsCalculationDemo.xcodeproj/xcuserdata/FishYu.xcuserdatad/xcschemes/YWDecimalsCalculationDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /YWDecimalsCalculationDemo.xcodeproj/xcuserdata/FishYu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | YWDecimalsCalculationDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 66F52CF21DCC3AA700FCCE15 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /YWDecimalsCalculationDemo.xcodeproj/xcuserdata/gaolailong.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /YWDecimalsCalculationDemo.xcodeproj/xcuserdata/gaolailong.xcuserdatad/xcschemes/YWDecimalsCalculationDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 33 | 34 | 40 | 41 | 42 | 43 | 44 | 45 | 56 | 58 | 64 | 65 | 66 | 67 | 68 | 69 | 75 | 77 | 83 | 84 | 85 | 86 | 88 | 89 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /YWDecimalsCalculationDemo.xcodeproj/xcuserdata/gaolailong.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | YWDecimalsCalculationDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 66F52CF21DCC3AA700FCCE15 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /YWDecimalsCalculationDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // YWDecimalsCalculationDemo 4 | // 5 | // Created by FishYu on 16/11/4. 6 | // Copyright © 2016年 codeFisher. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /YWDecimalsCalculationDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // YWDecimalsCalculationDemo 4 | // 5 | // Created by FishYu on 16/11/4. 6 | // Copyright © 2016年 codeFisher. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /YWDecimalsCalculationDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /YWDecimalsCalculationDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /YWDecimalsCalculationDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 56 | 66 | 76 | 86 | 96 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /YWDecimalsCalculationDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /YWDecimalsCalculationDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // YWDecimalsCalculationDemo 4 | // 5 | // Created by FishYu on 16/11/4. 6 | // Copyright © 2016年 codeFisher. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /YWDecimalsCalculationDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // YWDecimalsCalculationDemo 4 | // 5 | // Created by FishYu on 16/11/4. 6 | // Copyright © 2016年 codeFisher. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "NSString+DecimalsCalculation.h" 11 | 12 | @interface ViewController () 13 | 14 | @property (weak, nonatomic) IBOutlet UITextField *firstTextfield; 15 | @property (weak, nonatomic) IBOutlet UITextField *secondTextfield; 16 | @property (weak, nonatomic) IBOutlet UILabel *labResult; 17 | 18 | @property (nonatomic, weak) UIButton *selectedBtn; 19 | @property (weak, nonatomic) IBOutlet UIButton *plusBtn; 20 | 21 | @end 22 | 23 | @implementation ViewController 24 | 25 | - (void)viewDidLoad { 26 | [super viewDidLoad]; 27 | [self btnSelected:self.plusBtn]; 28 | 29 | } 30 | 31 | - (IBAction)btnSelected:(UIButton *)sender { 32 | if (self.selectedBtn != sender) { 33 | self.selectedBtn.selected = NO; 34 | sender.selected = YES; 35 | self.selectedBtn = sender; 36 | } 37 | } 38 | 39 | 40 | 41 | - (IBAction)getResult:(UIButton *)sender { 42 | NSString *str = nil; 43 | 44 | 45 | switch (self.selectedBtn.tag) { 46 | case 1: // 不保留小数点,四舍五入 47 | str = [self.firstTextfield.text yw_stringByAdding:self.secondTextfield.text withRoundingMode:NSRoundPlain scale:0]; 48 | break; 49 | case 2: // 保留一位小数,向下取整 50 | str = [self.firstTextfield.text yw_stringBySubtracting:self.secondTextfield.text withRoundingMode:NSRoundDown scale:1]; 51 | break; 52 | case 3: // 保留三位小数,向上取整 53 | str = [self.firstTextfield.text yw_stringByMultiplyingBy:self.secondTextfield.text withRoundingMode:NSRoundPlain scale:3]; 54 | break; 55 | case 4: // 保留两位小数,四舍五入 56 | str = [self.firstTextfield.text yw_stringByDividingBy:self.secondTextfield.text]; 57 | break; 58 | default: 59 | break; 60 | } 61 | 62 | self.labResult.text = str; 63 | } 64 | 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /YWDecimalsCalculationDemo/YWDecimalsCalculation/NSString+DecimalsCalculation.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+DecimalsCalculation.h 3 | // YWDecimalsCalculation 4 | // 5 | // Created by FishYu on 16/11/4. 6 | // Copyright © 2016年 codeFisher. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /** 12 | // Rounding policies : 13 | // Original 14 | // value 1.2 1.21 1.25 1.35 1.27 15 | // Plain 1.2 1.2 1.3 1.4 1.3 16 | // Down 1.2 1.2 1.2 1.3 1.2 17 | // Up 1.2 1.3 1.3 1.4 1.3 18 | // Bankers 1.2 1.2 1.2 1.4 1.3 19 | 20 | typedef NS_ENUM(NSUInteger, NSRoundingMode) { 21 | NSRoundPlain, // 四舍五入 22 | NSRoundDown, // 向下取舍 23 | NSRoundUp, // 向上入 24 | NSRoundBankers // 同四舍五入。但是当需要进位的数字是5时根据前一位的奇偶性,奇数向上取值、偶数向下取值 25 | }; 26 | */ 27 | 28 | @interface NSString (DecimalsCalculation) 29 | 30 | // 数字字符比较 31 | /* 32 | @return NSComparisonResult 33 | NSOrderedAscending = -1L, NSOrderedSame, NSOrderedDescending 34 | 当前数小于numberString 当前数等于numberString 当前数大于numberString 35 | */ 36 | - (NSComparisonResult)yw_numberStringCompare:(NSString *)numberString; 37 | // 加 38 | /** 39 | 加法计算,默认保留两位小数,默认采用四舍五入的方式处理计算结果, 40 | roundingModel决定四舍五入的方式,scale决定保留小数个数 41 | @param stringNumber 被加数 42 | @return 返回结果 43 | */ 44 | - (NSString *)yw_stringByAdding:(NSString *)stringNumber; 45 | - (NSString *)yw_stringByAdding:(NSString *)stringNumber withRoundingMode:(NSRoundingMode)roundingModel; 46 | - (NSString *)yw_stringByAdding:(NSString *)stringNumber withRoundingMode:(NSRoundingMode)roundingModel scale:(NSInteger)scale; 47 | 48 | // 减 49 | /** 50 | 减法计算,默认保留两位小数,默认采用四舍五入的方式处理计算结果 51 | roundingModel决定四舍五入的方式,scale决定保留小数个数 52 | @param stringNumber 减数 53 | @return 返回结果 54 | */ 55 | - (NSString *)yw_stringBySubtracting:(NSString *)stringNumber; 56 | - (NSString *)yw_stringBySubtracting:(NSString *)stringNumber withRoundingMode:(NSRoundingMode)roundingModel; 57 | - (NSString *)yw_stringBySubtracting:(NSString *)stringNumber withRoundingMode:(NSRoundingMode)roundingModel scale:(NSInteger)scale; 58 | 59 | // 乘 60 | /** 61 | 乘法计算,默认保留两位小数,默认采用四舍五入的方式处理计算结果 62 | roundingModel决定四舍五入的方式,scale决定保留小数个数 63 | @param stringNumber 减数 64 | @return 返回结果 65 | */ 66 | - (NSString *)yw_stringByMultiplyingBy:(NSString *)stringNumber; 67 | - (NSString *)yw_stringByMultiplyingBy:(NSString *)stringNumber withRoundingMode:(NSRoundingMode)roundingModel; 68 | - (NSString *)yw_stringByMultiplyingBy:(NSString *)stringNumber withRoundingMode:(NSRoundingMode)roundingModel scale:(NSInteger)scale; 69 | 70 | // 除 71 | /** 72 | 除法计算,默认保留两位小数,默认采用四舍五入的方式处理计算结果 73 | roundingModel决定四舍五入的方式,scale决定保留小数个数 74 | @param stringNumber 减数 75 | @return 返回结果 76 | */ 77 | - (NSString *)yw_stringByDividingBy:(NSString *)stringNumber; 78 | - (NSString *)yw_stringByDividingBy:(NSString *)stringNumber withRoundingMode:(NSRoundingMode)roundingModel; 79 | - (NSString *)yw_stringByDividingBy:(NSString *)stringNumber withRoundingMode:(NSRoundingMode)roundingModel scale:(NSInteger)scale; 80 | 81 | @end 82 | 83 | -------------------------------------------------------------------------------- /YWDecimalsCalculationDemo/YWDecimalsCalculation/NSString+DecimalsCalculation.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+DecimalsCalculation.m 3 | // YWDecimalsCalculation 4 | // 5 | // Created by FishYu on 16/11/4. 6 | // Copyright © 2016年 codeFisher. All rights reserved. 7 | // 8 | 9 | #import "NSString+DecimalsCalculation.h" 10 | 11 | // CalculationType 12 | typedef NS_ENUM(NSInteger,CalculationType){ 13 | CalculationAdding, 14 | CalculationSubtracting, 15 | CalculationMultiplying, 16 | CalculationDividing, 17 | }; 18 | 19 | @implementation NSString (DecimalsCalculation) 20 | // Compare 21 | - (NSComparisonResult)yw_numberStringCompare:(NSString *)numberString { 22 | NSDecimalNumber *selfNumber = [NSDecimalNumber decimalNumberWithString:self]; 23 | NSDecimalNumber *calcuationNumber = [NSDecimalNumber decimalNumberWithString:numberString]; 24 | return [selfNumber compare:calcuationNumber]; 25 | } 26 | // Adding 27 | - (NSString *)yw_stringByAdding:(NSString *)stringNumber { 28 | return [self yw_stringByAdding:stringNumber withRoundingMode:NSRoundPlain scale:2]; 29 | } 30 | - (NSString *)yw_stringByAdding:(NSString *)stringNumber withRoundingMode:(NSRoundingMode)roundingModel { 31 | return [self yw_stringByAdding:stringNumber withRoundingMode:roundingModel scale:2]; 32 | } 33 | - (NSString *)yw_stringByAdding:(NSString *)stringNumber withRoundingMode:(NSRoundingMode)roundingModel scale:(NSInteger)scale { 34 | return [self _stringByCalculationType:CalculationAdding by:stringNumber roundingMode:roundingModel scale:scale]; 35 | } 36 | 37 | // Substracting 38 | - (NSString *)yw_stringBySubtracting:(NSString *)stringNumber { 39 | return [self yw_stringBySubtracting:stringNumber withRoundingMode:NSRoundPlain scale:2]; 40 | } 41 | - (NSString *)yw_stringBySubtracting:(NSString *)stringNumber withRoundingMode:(NSRoundingMode)roundingModel { 42 | return [self yw_stringBySubtracting:stringNumber withRoundingMode:roundingModel scale:2]; 43 | } 44 | - (NSString *)yw_stringBySubtracting:(NSString *)stringNumber withRoundingMode:(NSRoundingMode)roundingModel scale:(NSInteger)scale { 45 | return [self _stringByCalculationType:CalculationSubtracting by:stringNumber roundingMode:roundingModel scale:scale]; 46 | } 47 | 48 | // Multiplying 49 | - (NSString *)yw_stringByMultiplyingBy:(NSString *)stringNumber { 50 | return [self yw_stringByMultiplyingBy:stringNumber withRoundingMode:NSRoundPlain scale:2]; 51 | } 52 | - (NSString *)yw_stringByMultiplyingBy:(NSString *)stringNumber withRoundingMode:(NSRoundingMode)roundingModel { 53 | return [self yw_stringByMultiplyingBy:stringNumber withRoundingMode:roundingModel scale:2]; 54 | } 55 | - (NSString *)yw_stringByMultiplyingBy:(NSString *)stringNumber withRoundingMode:(NSRoundingMode)roundingModel scale:(NSInteger)scale { 56 | return [self _stringByCalculationType:CalculationMultiplying by:stringNumber roundingMode:roundingModel scale:scale]; 57 | } 58 | 59 | // Dividing 60 | - (NSString *)yw_stringByDividingBy:(NSString *)stringNumber { 61 | return [self yw_stringByDividingBy:stringNumber withRoundingMode:NSRoundPlain scale:2]; 62 | } 63 | - (NSString *)yw_stringByDividingBy:(NSString *)stringNumber withRoundingMode:(NSRoundingMode)roundingModel { 64 | return [self yw_stringByDividingBy:stringNumber withRoundingMode:roundingModel scale:2]; 65 | } 66 | - (NSString *)yw_stringByDividingBy:(NSString *)stringNumber withRoundingMode:(NSRoundingMode)roundingModel scale:(NSInteger)scale { 67 | return [self _stringByCalculationType:CalculationDividing by:stringNumber roundingMode:roundingModel scale:scale]; 68 | } 69 | 70 | 71 | - (NSString *)_stringByCalculationType:(CalculationType)type by:(NSString *)stringNumber roundingMode:(NSRoundingMode)roundingModel scale:(NSUInteger)scale{ 72 | 73 | NSDecimalNumber *selfNumber = [NSDecimalNumber decimalNumberWithString:self]; 74 | NSDecimalNumber *calcuationNumber = [NSDecimalNumber decimalNumberWithString:stringNumber]; 75 | NSDecimalNumberHandler *handler = [[NSDecimalNumberHandler alloc] initWithRoundingMode:roundingModel scale:scale raiseOnExactness:NO raiseOnOverflow:NO raiseOnUnderflow:NO raiseOnDivideByZero:YES]; 76 | 77 | NSDecimalNumber *result = nil; 78 | switch (type) { 79 | case CalculationAdding: 80 | result = [selfNumber decimalNumberByAdding:calcuationNumber withBehavior:handler]; 81 | break; 82 | case CalculationSubtracting: 83 | result = [selfNumber decimalNumberBySubtracting:calcuationNumber withBehavior:handler]; 84 | break; 85 | case CalculationMultiplying: 86 | result = [selfNumber decimalNumberByMultiplyingBy:calcuationNumber withBehavior:handler]; 87 | break; 88 | case CalculationDividing: 89 | result =[selfNumber decimalNumberByDividingBy:calcuationNumber withBehavior:handler]; 90 | break; 91 | } 92 | 93 | // 使用自定义formatter 94 | NSNumberFormatter *numberFormatter = [self _numberFormatterWithScale:scale]; 95 | return [numberFormatter stringFromNumber:result]; 96 | } 97 | 98 | - (NSNumberFormatter *)_numberFormatterWithScale:(NSInteger)scale{ 99 | static NSNumberFormatter *numberFormatter; 100 | static dispatch_once_t onceToken; 101 | dispatch_once(&onceToken, ^{ 102 | numberFormatter = [[NSNumberFormatter alloc] init]; 103 | numberFormatter.minimumIntegerDigits = 1; 104 | numberFormatter.numberStyle = kCFNumberFormatterNoStyle; 105 | }); 106 | numberFormatter.alwaysShowsDecimalSeparator = !(scale == 0); 107 | numberFormatter.minimumFractionDigits = scale; 108 | return numberFormatter; 109 | } 110 | 111 | @end 112 | 113 | -------------------------------------------------------------------------------- /YWDecimalsCalculationDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // YWDecimalsCalculationDemo 4 | // 5 | // Created by FishYu on 16/11/4. 6 | // Copyright © 2016年 codeFisher. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | --------------------------------------------------------------------------------