标签: swift
我试图检查十进制数字是否为负数。尝试:
if value._isNegative { ... }
但它会出现错误'UInt32' is not convertible to 'Bool'
'UInt32' is not convertible to 'Bool'
答案 0 :(得分:3)
let value: Double = -5.0 value.sign == .minus ? print("negative") : print("positive")
答案 1 :(得分:2)
尝试使用值< 0.这将检查该值是否小于0.