Ciao.
allora devo fare un rand del tipo
rand(-2.0,+2.0)
quindi con risultati possibili (sia negativi che positivi) -2.0 +1.2 -0.8 etc etc
ma a quanto pare fatto così non va.
qual'è la sintassi esatta? thx
Ciao.
allora devo fare un rand del tipo
rand(-2.0,+2.0)
quindi con risultati possibili (sia negativi che positivi) -2.0 +1.2 -0.8 etc etc
ma a quanto pare fatto così non va.
qual'è la sintassi esatta? thx
http://codecanyon.net/category/all?ref=Manuelandro
And I bet she told a million people that she'd stay in touch, Well all the little promises they dont mean much,When theres
memories to be made
mi correggo.
fatto con questa sintassi non da errore, ma stampa -2, -1, 0, e 2
a me servono decimali.
come faccio?
http://codecanyon.net/category/all?ref=Manuelandro
And I bet she told a million people that she'd stay in touch, Well all the little promises they dont mean much,When theres
memories to be made
up
http://codecanyon.net/category/all?ref=Manuelandro
And I bet she told a million people that she'd stay in touch, Well all the little promises they dont mean much,When theres
memories to be made
Codice PHP:
echo mt_rand(-2 * 10, 2 * 10) / 10;
mitico grazie.
un'ultima domnda riguardante il modo d'uso di questa percentuale.
io facio una query del tipo
Codice PHP:
UPDATE tab SET cam = cam + ((cam + $rand_microton)/100)
solo che quando il rand è negativo la query non sottrae ma aggiunge le percentuale. come mai?
http://codecanyon.net/category/all?ref=Manuelandro
And I bet she told a million people that she'd stay in touch, Well all the little promises they dont mean much,When theres
memories to be made
Il numero casuale lo puoi generare anche con l'sql così
SELECT (FLOOR(-20 + (RAND() * 40)))/10;
esempio
se il funzionamento è quello che ti aspetti lo applichi all'update.codice:select cam,cam + (FLOOR(-20 + (RAND() * 40)))/10 as variazione from tab