Could not find overload for -, although all arguments are two

I am trying to find the polynomial value from pr. Here is my code:

let x = Double(pr)
let x2 : Double = pow(x, 2.0)
let x3 : Double = pow(x, 3.0)
let x4 : Double = pow(x, 4.0)
let r = CGFloat( 4.8 * x4 - 10.4 * x3 + 5.7 * x2 + 1.05 * x + 0.95 )
let g = CGFloat( 4.8 * x4 - 8.8 * x3  + 3.3 * x2 + 1.65 * x + 0.0 )
let b = CGFloat(0.0)
let color = UIColor(red: r, green: g, blue: b, alpha: 1.0)
return color.CGColor

Not much to explain, it just gives an error compliers: "Could not find an overload for the" - "that receives the provided arguments I also tried to use. powf(x, 2)The types float everywhere. pr- a function CGFloatHere is a screenshot:. screenshot.

Thank!

+4
source share
1 answer

This seems to be a compiler error (and perhaps worth mentioning about the error in Apple). Compiler messages in the report navigator show

note: expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions
let g = CGFloat( 4.8 * x4 - 8.8 * x3  + 3.3 * x2 + 1.65 * x + 0.0 )
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:

let tmp = 4.8 * x4 - 10.4 * x3 + 5.7 * x2 + 1.05 * x + 0.95
let r = CGFloat( tmp )

. :

let tmp = (((4.8 * x - 10.4) * x + 5.7) * x + 1.05) * x + 0.95

x.

+5

All Articles