DocumentaciónALEATORIO(max)
Nombre
ALEATORIO - Genera un numero aleatorio.
Sinopsis
n = ALEATORIO(max)
Descripcion
Genera un valor aleatorio usando max como limite superior.
Se usa como primitiva interna para juegos, simulaciones, muestreos y utilidades del runtime.
Comportamiento
- Recibe un limite superior
max. - Retorna un valor numerico aleatorio dentro del rango manejado por el runtime.
Funciones API relacionadas
RAIZ()ABS()MAX()MIN()ENTERO()REDONDEO()
Parámetros
| Parámetro | Tipo | Descripción |
|---|---|---|
| max | NUMERICO | Limite superior del numero aleatorio. |
Valor de retorno
NUMERICO - Retorna un numero aleatorio.
Ejemplo
ejemplo.blox
FUNCION PRINCIPAL
INICIO
NUMERICO x, y0,y1,y2,y3,y4, z
x = 10
y0 = ALEATORIO(x) // Con 0 decimales
y1 = 1/10 * ALEATORIO(10*x) // Con 1 decimal
y2 = 1/100 * ALEATORIO(100*x) // Con 2 decimales
y3 = 1/1000 * ALEATORIO(1000*x) // Con 3 decimales
y4 = 1/10000 * ALEATORIO(10000*x) // Con 4 decimales
IMPRIMIR ("\n", y0:0)
IMPRIMIR ("\n", y1:1)
IMPRIMIR ("\n", y2:2)
IMPRIMIR ("\n", y3:3)
IMPRIMIR ("\n", y4:4)
FINAL