重構小數轉整數
This commit is contained in:
@@ -115,10 +115,12 @@ class Calculator {
|
|||||||
if ["+", "-", "×", "÷"].firstIndex(of: formula.last!) != nil {
|
if ["+", "-", "×", "÷"].firstIndex(of: formula.last!) != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (Double(formula.last!)! / 100).truncatingRemainder(dividingBy: 1) != 0 {
|
formula.append(String(Double(formula.popLast()!)! / 100))
|
||||||
formula.append(String(Double(formula.popLast()!)! / 100))
|
if Double(formula.last!)!.truncatingRemainder(dividingBy: 1) == 0 {
|
||||||
} else {
|
var number = formula.popLast()!
|
||||||
formula.append(String(Int(formula.popLast()!)! / 100))
|
number.removeLast()
|
||||||
|
number.removeLast()
|
||||||
|
formula.append(number)
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user