Remove trailing zero's from Double swift iOS

Solution:

If you had an output that contains 0.1 it will return 0.1.If it was 1.0 it will return 1.If it was 1.1 it return 1.1

func forTrailingZero(temp: Double) -> String {
    var roundDouble = String(format: "%g", temp)
    return roundDouble
}

Function Call:

Var doub = 3.0

forTrailingZero(doub)   //3

Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Saved Image in document directory and save path in coredata not able to fetch the image file iOS swift