🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #15336

Re: Números aleatorios

#15336
From: kuantiko
Date: Sat, 08 Jul 2000 00:00
56 lines
2144 bytes
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jayr Al-Dyn escribió:
> 
> Pues haciéndole el módulo del número. Si lo que quieres son
> números entre 0 y N, basta con que le hagas módulo N+1.
> 
> La función en C para el módulo es el signo del porcentaje.
> 
> Por ejemplo:
> 
> #include <stdio.h>
> 
> int main() { printf("%d\n", 28772 % 101);
> }
> 

	Según tengo entendido, este modo de hallar el número no es
completamente aleatorio y, por alguna razón matemática que no puedo
explicar, favorece a los números mayores del sesentaypico por ciento
(creo) del límite que buscas. La forma correcta sería, suponiendo que
quieras hallar un número del 0 al 100, dividir el aleatorio inicial
entre RAND_MAX y multiplicar el resultado por 100.

Un saludo, y espero no meter el zueco.
- -- 
 
Jesús Carrete Montaña ----> KUANTIKO
 ___________________________________________ 
|    .~.                                    |
|    /V\     jrcarmon(arroba)teleline.es    |
|   // \\    Linux Registered               |
|  /(   )\   User #158442                   |
|   ^`~'^                                   |
|___________________________________________|

Clave pública PGP disponible por e-mail.

-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5.1i for non-commercial use <http://www.pgpi.com/>

iQA/AwUBOWeAxlXBzV6UX+HYEQKavACeLzQW9PG4CfbCtBB4FxOavmvUu1sAn1Wk
+DdPqx9K9gY8TlOpyOo+LsNR
=Um14
-----END PGP SIGNATURE-----
Technical Details
Message-ID: <39678ED7.220F6D37@teleline.es>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <E_H95.144$pA2.4012@m2newsread.uni2.es> <396756C2.8E2404AE@en.ninguna.parte>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,9e48787536054c7
X-Google-Attributes: gidf86c8,public
From: kuantiko <jrcarmon@teleline.es>
Subject: Re: Números aleatorios
Date: 2000/07/08
Message-ID: <39678ED7.220F6D37@teleline.es>
X-Deja-AN: 644186453
Content-Transfer-Encoding: quoted-printable
References: <E_H95.144$pA2.4012@m2newsread.uni2.es> <396756C2.8E2404AE@en.ninguna.parte>
X-Accept-Language: es
Content-Type: text/plain; charset=iso-8859-1
Organization: Quanta Studios
Mime-Version: 1.0
Reply-To: jrcarmon@teleline.es
Newsgroups: es.comp.os.linux.programacion