[swift] Rounding a double value to x number of decimal places in swift

I would use

print(String(format: "%.3f", totalWorkTimeInHours))

and change .3f to any number of decimal numbers you need