Comunidad de diseño web y desarrollo en internet online

numero aleatorio entre 10 y 20

Citar            
MensajeEscrito el 18 Sep 2004 10:37 pm
Hola amigos, yo de nuevo. Me pregunto cómo podría hacer para generar un numero aleatorio en as entre 10 y 20 por ejemplo

Por Smithy

159 de clabLevel



Genero:Masculino  

unknown
Citar            
MensajeEscrito el 18 Sep 2004 11:09 pm
utiliza random(x), te devolverá un número entero entre 0 y x, luego sólo debes agregarle una constante, como valor mínimo

saludos

Por fael

BOFH

2443 de clabLevel

3 tutoriales
2 articulos

 

unknown
Citar            
MensajeEscrito el 18 Sep 2004 11:41 pm

Código :

function aleatorio (min : Number, max : Number, decimas : Number) : Number 
   {
      //Joey Slott (ActionScript Cookbook)
      //te saca un numero aleatorio de un rango
      if (decimas == undefined) decimas = 0;
      var diffPlage = (max - min) * Math.pow (10, decimas) + 1;
      var valAleatoire = Math.random () * diffPlage;
      valAleatoire = Math.floor (valAleatoire);
      valAleatoire /= Math.pow (10, decimas);
      return valAleatoire += min;
   }

Por buho29

510 de clabLevel

1 tutorial

7 ejemplos

 

unknown
Citar            
MensajeEscrito el 19 Sep 2004 12:00 am

Código :

trace(1+random(10));

Por Freddie

BOFH

53 tutoriales
597 articulos
43 ejemplos

Genero:Masculino   Admin

Conserje de Cristalab

unknown
Citar            
MensajeEscrito el 19 Sep 2004 12:04 am
gracias por las respuestas. son unos masters 8)

Por Smithy

159 de clabLevel



Genero:Masculino  

unknown

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.