3 ms·
stuff like this can't help var n = Double(arc4random_uniform(UInt32(weightTotal * 1000000.0))) / 1000000.0
by CorvusCrypto 10y ago
stuff like this can't help
var n = Double(arc4random_uniform(UInt32(weightTotal * 1000000.0))) / 1000000.0
- brothrock 10y agoYep totally, going to take another pass to try and make it faster. This was just a make it work experiment. Had a few fun troubles with random, but at the moment it just crawls :(.
- sdegutis 10y agoOut of curiosity, what's wrong with that line? Why is it slow?
- CorvusCrypto 10y agostarting from inside the arc4random call you have double float multiplication, then cast to uint32, then the arc4rand call, then the double cast for the uint32 result and then a double float division. this adds up in instructions.