当我进入分区时,我正在尝试创建关于数学测试的应用程序。我知道我不能创建重复的无限小数,我必须保持数字随机。因此,在我从 arc4random_uniform 生成数字之后,我正在尝试使用 round 函数。但它说
找不到接受参数类型 (Int) 的轮次重载
我该如何解决?
这是我的代码:
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))
}