Posted: Tue Jul 04, 2006 9:00 am Post subject: large counted loop
if you have to go to a very large number in a counted loop, it will say integer too large. so how would i do that? i tried using BigInteger, but it is not working and i'm not too sure if that is right?
Sponsor Sponsor
r.3volved
Posted: Tue Jul 04, 2006 12:10 pm Post subject: (No subject)
counted loop as in a 'for' loop??
long myNum = 0;
while(myNum != 623456823746L)
{
++myNum;
}
if it's so long that it won't let you do a for loop, then a forloop probably isn't the best aproach
cool dude
Posted: Tue Jul 04, 2006 1:26 pm Post subject: (No subject)
r.3volved wrote:
counted loop as in a 'for' loop??
long myNum = 0;
while(myNum != 623456823746L)
{
++myNum;
}
if it's so long that it won't let you do a for loop, then a forloop probably isn't the best aproach
yes counted loop as a for loop. and i need the for loop.
p.s. why do you have a L at the end of the number?
TheFerret
Posted: Tue Jul 04, 2006 1:29 pm Post subject: (No subject)
You could have a different variable type in the counter if needed, like:
Java:
for(long i=0; i<584846484654; i++){ }
And that should work...
r.3volved
Posted: Tue Jul 04, 2006 2:23 pm Post subject: (No subject)
L denotes a long integer
Just as if you were to do:
float myNum = 0.0f; //can use 'f' or 'F'
instantiation I guess would be:
long myNum = 0L; //can use 'l' or 'L'
I'd imagine the long would work with no problems in a for loop.
I just tend to avoid for loops that are so long like that and choose another procedure.
Krabjuice
Posted: Tue Jul 04, 2006 5:05 pm Post subject: (No subject)