I'm trying to generate random value for sensors in tinyos, nesc. I want to have specific limits but what i get isn't exactly what i want. I want to get numbers between [nodeID, nodeID+20] My code is:
value = nodeID + rand()%(20 + (1 + nodeID));
Any ideas?
Aucun commentaire:
Enregistrer un commentaire