mIRC Homepage
Posted By: cyter Big Numbers - 17/04/03 01:59 AM
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?
Posted By: KingTomato Re: Big Numbers - 17/04/03 02:20 AM
on 1:TEXT:~rand*:#: {
if ($$2 isnum) && ($$2 <= 99999) {
/msg $chan Your Random Number Is: $rand(1, $$2)
}
}
Posted By: laz Re: Big Numbers - 17/04/03 08:06 AM
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.
Posted By: theRat Re: Big Numbers - 17/04/03 08:52 AM
Code:
on 1:text:~rand *:#: {
 if ( $$2 isnum 1-2147483647) {
     msg $chan $rand(0,$2)
 }
 else msg $chan Random number $rand(0,2147483647)
}
  
Posted By: Nimue Re: Big Numbers - 17/04/03 12:23 PM
Code:
on *:text:~rand &amp;:#:{
  if $2 isnum 2- msg # Rand: $r(1,$iif($2 &gt; 2147483647,2147483647,$2))
}
Posted By: codemastr Re: Big Numbers - 17/04/03 09:24 PM
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.
Posted By: KingTomato Re: Big Numbers - 18/04/03 03:03 PM
Isn't the largest number able to hand 4,294,967,295 , which would be unsigned long, correct? confused
Posted By: Nemo Re: Big Numbers - 18/04/03 03:20 PM
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
© mIRC Discussion Forums