Skip to content

Commit 27dc800

Browse files
author
Eric Wu
committed
修复doubleValue 取值问题
1 parent e1ce8d3 commit 27dc800

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

CRBoostSwift/Classes/Foundation+CRBoost.swift

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,8 @@ extension String {
260260
}
261261

262262
public var doubleValue: Double {
263-
if let d = Double(self) {
264-
return d
265-
} else if boolValue == true {
266-
return 1
267-
} else {
268-
return 0
269-
}
263+
let decimal = NSDecimalNumber(string: self)
264+
return decimal == .notANumber ? .zero : decimal.doubleValue
270265
}
271266

272267
public var floatValue: Float {

0 commit comments

Comments
 (0)