Text("Värde \(Double(calc2, specifier: "%.2f").rounded())") 
//ERROR
I am converting a Slider value that uses a double type, but i cant format specify it?
I get an error and xcode tells me to use signaling(?). I've tried putting it into an Int as well.
whats the right move here?
You can use
Text("Värde \(calc2, specifier: "%.2f")") 
to convert it to 2 decimals.
To have greater flexibility you can use formatter and leverage appendInterpolation on string. Use the below function or something to that effect
func customFormat(_ number: Double) -> String  {
   let customFormatter = NumberFormatter()
   customFormatter.roundingMode = .down
   customFormatter.maximumFractionDigits = 2
   return "\(number, formatter: customFormatter)"   
}
                        I assume you want something like
Text("Värde \(String(format: "%.2f", calc2))")
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With