I have this swift
code:
x = Float(arc4random_uniform(30))
y = Float(arc4random_uniform(30))
z = Float(arc4random_uniform(30))
coords.x = 0.00 - x
coords.y = 0.00 - y
coords.z = 0.00 - z
print("\(coords.x) \(coords.y) \(coords.z) xyz")
For some reason it always outputs the numbers as positive, I have also tried:
x = -Float(arc4random_uniform(30))
y = -Float(arc4random_uniform(30))
z = -Float(arc4random_uniform(30))
coords.x = x
coords.y = y
coords.z = z
and...
x = -1 * Float(arc4random_uniform(30))
y = -1 * Float(arc4random_uniform(30))
z = -1 * Float(arc4random_uniform(30))
coords.x = x
coords.y = y
coords.z = z
...and even one more where I had to cast the random number as an Int to multiply it by -1 within the Float
cast.
x = Float(arc4random_uniform(30))
y = Float(arc4random_uniform(30))
z = Float(arc4random_uniform(30))
coords.x = 0.00 - x
coords.y = 0.00 - y
coords.z = 0.00 - z
The console output is always something like:
24.0 27.0 29.0 xyz
...no negative numbers.
What am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire