iOS 除法 百分比
2020-06-28 本文已影响0人
gaookey
let num1 = 100.0 / 1000.0
let num2 = CGFloat(100.0) / 1000.0
let num3 = 100.0 / CGFloat(1000.0)
let num4 = CGFloat(100.0 / 1000.0)
print("num1=\(num1)")
print("num2=\(num2)")
print("num3=\(num3)")
print("num4=\(num4)")
let num5 = 1.0 / 2.0
let num6 = CGFloat(1.0) / 2.0
let num7 = 1.0 / CGFloat(2.0)
let num8 = CGFloat(1.0 / 2.0)
print("num5=\(num5)")
print("num6=\(num6)")
print("num7=\(num7)")
print("num8=\(num8)")
num1=0.1
num2=0.1
num3=0.1
num4=0.1
num5=0.5
num6=0.5
num7=0.5
num8=0.5
let num1: CGFloat = 100 / 1000
let num2: CGFloat = CGFloat(100) / 1000
let num3: CGFloat = 100 / CGFloat(1000)
let num4: CGFloat = CGFloat(100 / 1000)
print("num1=\(num1)")
print("num2=\(num2)")
print("num3=\(num3)")
print("num4=\(num4)")
let num5: CGFloat = 1 / 2
let num6: CGFloat = CGFloat(1) / 2
let num7: CGFloat = 1 / CGFloat(2)
let num8: CGFloat = CGFloat(1 / 2)
print("num5=\(num5)")
print("num6=\(num6)")
print("num7=\(num7)")
print("num8=\(num8)")
num1=0.1
num2=0.1
num3=0.1
num4=0.0
num5=0.5
num6=0.5
num7=0.5
num8=0.0
let num1 = 100 / 1000
let num2 = CGFloat(100) / 1000
let num3 = 100 / CGFloat(1000)
let num4 = CGFloat(100 / 1000)
print("num1=\(num1)")
print("num2=\(num2)")
print("num3=\(num3)")
print("num4=\(num4)")
let num5 = 1 / 2
let num6 = CGFloat(1) / 2
let num7 = 1 / CGFloat(2)
let num8 = CGFloat(1 / 2)
print("num5=\(num5)")
print("num6=\(num6)")
print("num7=\(num7)")
print("num8=\(num8)")
num1=0
num2=0.1
num3=0.1
num4=0.0
num5=0
num6=0.5
num7=0.5
num8=0.0