vendredi 24 novembre 2017

how to solve that random gives false numbers

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