vendredi 20 janvier 2017

Swift-Binary operator cannot be applied to operands, when converting degrees to radians

I'm aware of some relatively similar questions on this site, but if they do apply to my problem (which I'm not certain they do) then I certainly don't understand them. Here's my problem;

var degrees = UInt32()
var radians = Double()

let degrees:UInt32 = arc4random_uniform(360)
let radians = angle * (M_PI / 180)

This returns an error, focused on the multiplication star, reading; "Binary operator "*" cannot be applied to operands of type 'UInt32' and 'Double'.

I'm fairly sure I need to have the degrees variable be of type UInt32 to randomise it, and also that the pi constant cannot be made to be of UInt32, or at least I don't know how, as I'm relatively new to Xcode and Swift in general.

I'd be very grateful if anyone had a solution to my problem.

Thanks in advance.




Aucun commentaire:

Enregistrer un commentaire