I'm trying to create my app about a math test as I come to division. I know that I can't create repeating infinite decimals, and I must keep the numbers random. So after I generated the numbers out of arc4random_uniform, I'm trying to use the round function. But it said
Cannot find an overload for round that accepts argument type (Int)
How do I fix this?
Here's my code:
var randomNumber:UInt32 = arc4random_uniform(999)
var randomNumber2:UInt32 = arc4random_uniform(999)
// 1000 is my maximum number for now.
randomNumber += 1
randomNumber2 += 1
if operation.text == "/" {
if randomNumber < randomNumber2 {
var between:UInt32 = 1000 - randomNumber2
randomNumber = randomNumber2 + arc4random_uniform(between - 1)
// making sure that randomNumber is not smaller than randomNumber2,
// therefore all results are positive.
}
var answer:Int = round(Int(randomNumber)/Int(randomNumber2))
}
You have to pass a Float
value to round
since it doesn't have prototypes using Int
value:
var answer = round(Float(randomNumber)/Float(randomNumber2))