We are about to switch to a new forum software. Until then we have removed the registration on this forum.
i want to pick either -4 or 4 not inbetween
int rnd = random(1) < .5? -4 : 4;
if(random(100) < 50)
In your case, conceptually, some of the many options:
you can imagine multiplying 4 by a random (1 or -1),
more generally you can imagine testing a random (0-1) to see if it is above or below .5, then choose one of two numbers accordingly.
You could create a list of numbers and then choose one by shuffling.
The last approach is much more useful if you needed more than one choice and you need them to be unique, but it conceptually works like the sides of a coin or deck of cards: if you shuffle (4, -4) and then take the top number, it is one or the other.