I have a signed random integer in range A..B. What is the formula to map from A..B into a subrange C..D where C >= A and D <= B?
For unsigned integers, I can use A + (num % (B - A)). What's the equivalent of this for signed?
Aucun commentaire:
Enregistrer un commentaire