我有字符串值并转换为double值以添加它。但它在调试时显示不同的值。在使用print语句时它显示正确的值,但是当在控制台中使用“po”命令显示不同时,所以获得不同的结果然后预期一个。
let stringValue = "83.84"
let doubleValue = Double(stringValue)
let floatValue = Float(stringValue)
let decimalArray: Array<Double> = [doubleValue!, doubleValue!, doubleValue!]
let test1 = decimalArray.reduce(0, combine: +)
let floatArray: Array<Float> = [floatValue!, floatValue!, floatValue!]
let test2 = floatArray.reduce(0, combine: +)
print(test1)
print(test2)
答案 0 :(得分:0)
我认为您在正确转换之前使用的是po
。只在最后一行breakpoint
放置print(test2)
,然后检查。