mIRC Home    About    Download    Register    News    Help

Print Thread
Big Numbers #19763 17/04/03 01:59 AM
Joined: Dec 2002
Posts: 5
C
cyter Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Dec 2002
Posts: 5
I have this script to pick a random number based on what the person says, but it can't handle big numbers.

For example, someone says ~rand 565
Then it'll pick a number from 1 to 565

However, when someone types in a huge number, such as 999999999999999999999999999999999999999999999999, it'll crash. I've seen another person with this type of script, however when someone enters in a big number it limits to 2147483647. How do they do that?

Re: Big Numbers #19764 17/04/03 02:20 AM
Joined: Jan 2003
Posts: 3,012
KingTomato Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
on 1:TEXT:~rand*:#: {
if ($$2 isnum) && ($$2 <= 99999) {
/msg $chan Your Random Number Is: $rand(1, $$2)
}
}


-KingTomato
Re: Big Numbers #19765 17/04/03 08:06 AM
Joined: Dec 2002
Posts: 54
L
laz Offline
Babel fish
Offline
Babel fish
L
Joined: Dec 2002
Posts: 54
Code:
  
on 1:text:~rand *:#: {
 if ($$2 isnum) {
     msg $chan $iif($2 &lt; 9999999999,Random number: $rand(0,999999999),Random number: $rand(0,$2))
 }
 else msg $chan Digits only, please.
}


Should work.

Re: Big Numbers #19766 17/04/03 08:52 AM
Joined: Dec 2002
Posts: 774
T
theRat Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Dec 2002
Posts: 774
Code:
on 1:text:~rand *:#: {
 if ( $$2 isnum 1-2147483647) {
     msg $chan $rand(0,$2)
 }
 else msg $chan Random number $rand(0,2147483647)
}
  


Code:
//if ( khaled isgod ) echo yes | else echo no
Re: Big Numbers #19767 17/04/03 12:23 PM
Joined: Dec 2002
Posts: 699
N
Nimue Offline
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 699
Code:
on *:text:~rand &amp;:#:{
  if $2 isnum 2- msg # Rand: $r(1,$iif($2 &gt; 2147483647,2147483647,$2))
}

Re: Big Numbers #19768 17/04/03 09:24 PM
Joined: Dec 2002
Posts: 2,809
C
codemastr Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
If you need a number as large as 999999999999999999999999999999999999999999999999 then you will have to write a DLL. Neither mIRC, nor Windows, nor the x86 architecture support numbers that large. This means you'd have to write the code to do it yourself since the system can't.

Re: Big Numbers #19769 18/04/03 03:03 PM
Joined: Jan 2003
Posts: 3,012
KingTomato Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
Isn't the largest number able to hand 4,294,967,295 , which would be unsigned long, correct? confused


-KingTomato
Re: Big Numbers #19770 18/04/03 03:20 PM
Joined: Apr 2003
Posts: 18
N
Nemo Offline
Pikka bird
Offline
Pikka bird
N
Joined: Apr 2003
Posts: 18
With quadwords you can store 8 bytes, which is 64 bits. 2^64 = 18,446,744,073,709,551,615, however there aren't many instructions for the 386+ 32-bit architecture that support quadwords (there are a couple though). I would assume that a 64-bit processor architecture would support a lot more quadword instructions... well, if it's a CISC anyway; a RISC probably wouldn't have very many.
But yes, with the usual x86 instruction set, 4,294,967,295 is the largest unsigned number (doubleword size) you can store.
Of course, here we are using floating point operations, so it's a little bit different, since FP numbers are stored in the IEEE floating point format, so the limit of 4,294,967,295 doesn't really apply. I haven't studied floating point operations much yet on the x86, so I don't know how large the registers are, so I don't know how big of numbers it would store, but I will find out and may reply again smile