I need to divide two double values and then round the results to the tenths place. How would I go about doing this? Thank you in advance!
Use this version of the
String(format: "%.1f", (total / rate))
There are other ways to do it, but this is probably the easiest.
BTW, you don’t need to do this:
private var rate = Double(8.25) @State private var total = Double(179.14)
179.14 are already implicitly
Doubles so you don’t need to convert them.
You can just do:
private var rate = 8.25 @State private var total = 179.14
Or, if you want to make the type annotation explicit:
private var rate: Double = 8.25 @State private var total: Double = 179.14
Perfect, Very helpful! thank you!