Shoutbox

Random number generator? - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Forum: Plug-Ins (/forumdisplay.php?fid=28)
+------ Thread: Random number generator? (/showthread.php?tid=29043)

Random number generator? by Phrive on 07-23-2004 at 01:40 PM

has any1 got a sourse code for a random number generator that generates one number bettween 1 and 10 i posted it in tech tlk but no reply plz i need it badly


RE: Random number generator? by KeyStorm on 07-23-2004 at 01:43 PM

It can't be so difficult, which language?


RE: Random number generator? by Phrive on 07-23-2004 at 01:44 PM

i have done it b4 and i was tryin 2 remeber it but i cudnt get it to work properly c++


RE: Random number generator? by Millenium_edition on 07-23-2004 at 01:44 PM

in vb it's

code:
Randomize
intRandomNumber = Int(Rnd * 99999)

c++? damn. sorry :s
RE: Random number generator? by KeyStorm on 07-23-2004 at 01:50 PM

randInt = ( rand() % 10 ) + 1;

or similar


RE: Random number generator? by Phrive on 07-23-2004 at 01:52 PM

kk ill try it !!


RE: Random number generator? by matty on 07-23-2004 at 02:18 PM

http://www.robertjacobs.fsnet.co.uk/random.htm

[Image: google.gif] <-- This is a link to a Google Search


RE: Random number generator? by Phrive on 07-23-2004 at 02:19 PM

cheers matty im almost there and thats hlped alot cheers i did search but i cudnt find anything


RE: Random number generator? by dotNorma on 07-23-2004 at 05:08 PM

Its all over google in any language :-/

code:
In Form_Load()
Randomize
End Sub

Public Function Rand(ByVal Low As Long, _
                     ByVal High As Long) As Long
  Rand = Int((High - Low + 1) * Rnd) + Low
End Function


(Visual Basics)

code:
include <cstdlib>
#include <iostream>

using namespace std;

int main()
{
    int random_integer = rand();
    cout << random_integer << endl;
}

   random_integer = (rand()%10);

(C++)


Notice the VB one makes sense while the C++ one just seems like a bunch of random jabber :p
RE: Random number generator? by RaceProUK on 07-24-2004 at 09:37 AM

You don't get truly random numbers anyway, just pseudorandom ones. There are iterative formulae that oscillate seemingly wildly between 0 and 1 that are used for random number generators, which is why a lot of them have seeds.


RE: RE: Random number generator? by LunarCrisis on 09-06-2004 at 04:41 AM

quote:
Originally posted by KeyStorm
randInt = ( rand() % 10 ) + 1;

or similar


Actually, since the low order bits are usually less random (using rand()) then the higher order bits, this would be more random:

randInt = (int)( rand() / (RAND_MAX + 1) * 10 + 1 )

the method previously posted uses only the lowest few bits (the least random), while this method relies mostly on the high order bits.

Yes, it's picky :p
RE: Random number generator? by CookieRevised on 09-06-2004 at 01:05 PM

maybe you can use the various dice roller plugins. They do nothing more then generating a random number (also between 1 and 10):

dierollerversion21 by Anthony Meaden:
http://shoutbox.menthix.net/showthread.php?tid=28...d=274813#pid274813

D&D dice roller by Baruchi:
http://shoutbox.menthix.net/showthread.php?tid=20319

Dice Roller by DJMystic:
http://shoutbox.menthix.net/showthread.php?tid=14720
(unavailable)