types - Confusion due to Swift lacking implicit conversion of CGFloat -


trying arithmetic in function returns `cgfloat, error:

couldn't find overload '/' accepts supplied arguments

func kdccontroldegreestoradians(x : cgfloat) -> cgfloat {       return (m_pi * (x) / 180.0) // error here.  } 

has else seen type of issue?

this problem double float conversion.

on 64-bit machine, cgfloat defined double , compile without problems because m_pi , x both doubles.

on 32-bit machine, cgfloat float m_pi still double. unfortunately, there no implicit casts in swift, have cast explicitly:

return (cgfloat(m_pi) * (x) / 180.0) 

the type 180.0 literal inferred.

in swift 3

m_pi deprecated, use cgfloat.pi instead:

return (x * .pi / 180.0) 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -