Home
Friday, December 19, 2014
7:41:55 PM
Users online: 0   You are here >> Home > Programming

Forums | Programming Forums search
Forum FAQ
   
  1  
Random number batch file
chrisbrownie 
23/10/05 12:06:15 AM
Apprentice

hey guys,

im having trouble making a batch file that generates random numbers, i dont care how many at once, i just want one that does it. i dont need anytinh cool or flashy just a randomnumber.bat

cheers

-----
From the Sunshine Coast? PM Me!

Sempron 2500+ @ 2.104Ghz, ASUS A7N8X-X, 768MB DDR400, 80GB Seagate 7200rpm, Tsunami 500W PSU, MSI NX6600GT ViVo, Raidmax Cobra, LG GSA-4120B+, Logitech MX-510

AIMBOT 
24/10/05 8:42:58 PM
Champion

http://www.robvanderwoude.com/batexamples_pr.html

-----
Bom-Bom, Rock the Nation!

The Broken Hammer, Defending our lovely "Search Feature"
http://www.atomicmpc.com.au/forums.asp?s=1&c=4&t=2439

pappes 
29/10/05 10:52:49 AM
Overlord

Aimbot that is a cool site.

however it does not mention that in win xp has a propper random number generater accessable to batch files. you can use
set myvar=%random%
to set the environment variabel myvar to random decimal number between 0 and 32767
you could the use somthing like
set /a (myvar*101/32768)+1
to get a number between 1 and 100



Edited by pappes: 29/10/2005 10:54:09 AM

-----
I am a genious, what's your excuse?

This message indicates that I, Pappes, won the 76-er challenge on the 18-09-05. If you would like to consider a sponsorship deal, please contact my manager - Shrewd - via pm. I am willing to pose naked.

setagllib 
29/10/05 11:27:24 AM
Banned

pappes: back to primary school for you. If it can be from 0..32767, and you multiply by 101 /32768 then add 1, it could be as high as 102.

To do this PROPERLY, break it down into variables:
min = 1 
max = 100
range = max-min = 99
minrand = 0
maxrand = 32767
rangerand = maxrand - minrand = 32767

number = (%random% - minrand) * range / rangerand + min
= %random% * 99 / 32767 + 1


And that will work properly.

But you call that a proper RNG? It's 7 bit PRNG for crying out loud. There is no reason at all not to have a full 32 bits of entropy, but Microsoft seems to think that 7 bits is "random enough for most people" or something. Go read up some information/data theory and cryptography to see why 7 bits is garbage.


Edited by setagllib: 29/10/2005 11:54:19 AM

-----

profile.c:42: error: `tagline' undeclared 
(first use in this function)

AIMBOT 
30/10/05 3:15:20 PM
Champion

A very simple way (Probably won't suite your needs) is:

To set a random number to your variable:
set myvar=%random%

And to view the number of your variable:
set myvar

-----
Bom-Bom, Rock the Nation!

The Broken Hammer, Defending our lovely "Search Feature"
http://www.atomicmpc.com.au/forums.asp?s=1&c=4&t=2439

setagllib 
30/10/05 3:29:59 PM
Banned

AIMBOT, we just went over that. Read the thread before posting.

-----

profile.c:42: error: `tagline' undeclared 
(first use in this function)

AIMBOT 
31/10/05 3:05:32 PM
Champion

Looks ^

Lol, that’ll learn me.

-----
Bom-Bom, Rock the Nation!

The Broken Hammer, Defending our lovely "Search Feature"
http://www.atomicmpc.com.au/forums.asp?s=1&c=4&t=2439

chrisbrownie 
2/11/05 8:48:27 PM
Disciple

lol thx ill keep having a fiddle

-----
From the Sunshine Coast? PM Me!

Sempron 2500+ @ 2.104Ghz, ASUS A7N8X-X, 768MB DDR400, 80GB Seagate 7200rpm, Tsunami 500W PSU, MSI NX6600GT ViVo, Raidmax Cobra, LG GSA-4120B+, Logitech MX-510

  1  
Forums | Programming