Can anyone tell me how to round a double value to x number of decimal places in Swift?
I have:
var totalWorkTimeInHours = (totalWorkTime/60/60)
How do I round this down to, say, 1.543 when I print totalWorkTimeInHours?
totalWorkTimeInHours
To round totalWorkTimeInHours to 3 digits for printing, use the String constructor which takes a format string:
String
format
print(String(format: "%.3f", totalWorkTimeInHours))