Swift - Remove Back Zeros from Two Sides

What is the function that removes trailing zeros from paired ones?

var double = 3.0 var double2 = 3.10 println(func(double)) // 3 println(func(double2)) // 3.1 
+7
double ios swift trailing
source share
1 answer

You can do it this way, but it will return a string:

 var double = 3.0 var double2 = 3.10 func forTrailingZero(temp: Double) -> String { var tempVar = String(format: "%g", temp) return tempVar } forTrailingZero(double) //3 forTrailingZero(double2) //3.1 
+24
source share

All Articles