Swift: Random number for 64-bit integers?

后端 未结 4 1479
孤城傲影
孤城傲影 2020-12-03 11:11

So, with my current project, I need to work with 64-bit integers and I need to grab random numbers between ranges up to 100 billion. arc4random()/arc4random_uniform() only w

4条回答
  •  悲&欢浪女
    2020-12-03 11:44

    Perhaps you can compose it of two 32 bit integers:

    var random64 = Int64(arc4random()) + (Int64(arc4random()) << 32)
    

提交回复
热议问题