所以想象一下,我希望我的代码在0.25中计算,我希望它像:0.00,0.25,0.50 ...但它目前是:0,0.25,0.5 ...... 我的代码中的那部分是这样的:
if (Score >= 0 && Score < 10.00){
Score += 0.25
HighScoreLabel.text = "The Score is \(Score)"
}
答案 0 :(得分:4)
let score = 0.5
let stringDisplay = String(format: "%.02f", score)
println("The Score is \(stringDisplay)") // "The Score is 0.50"