| Author |
Message |
zylum

|
Posted: Mon Jun 26, 2006 6:27 pm Post subject: (No subject) |
|
|
for(int i = 1; i <= 317584931803; i++){
317584931803 isnt exactly an integer... how is i, which is an integer type, supposed to go all the way up to that? |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
cool dude

|
Posted: Mon Jun 26, 2006 6:32 pm Post subject: (No subject) |
|
|
| even if i decrease the number it still says incompatible types. try it |
|
|
|
|
 |
HellblazerX

|
Posted: Mon Jun 26, 2006 7:35 pm Post subject: (No subject) |
|
|
You just forgot to do any comparing inside that if statement. You called compareTo (), but you never actually used or compared the value that it returned, so that's why its giving you that error.
| code: | if (num.mod(BigInteger.valueOf(i)).compareTo(BigInteger.ZERO) == 0) { |
And zylum's right. That number is too big for an int. Why not use BigIntegers instead in the for loop? |
|
|
|
|
 |
cool dude

|
Posted: Mon Jun 26, 2006 8:32 pm Post subject: (No subject) |
|
|
thanks. the thing that i don't understand is that when u say:
| code: |
compareTo(BigInteger.ZERO) |
doesn't that compare to zero already? why do u need to restate == 0 if it already compares it to zero  |
|
|
|
|
 |
wtd
|
|
|
|
 |
cool dude

|
Posted: Tue Jun 27, 2006 8:26 pm Post subject: (No subject) |
|
|
i'm trying to make my counted loop be able to go to a huge number, thus i am trying to use BigInteger again. i dunno why but BigInteger just doesn't seem to stick to my head if anyone could make a tutorial that would be great. i tried doing the counted loop but it says: Quote: operator < cannot be applied to BigInteger
| code: |
for(int i = 1; (num.compareTo(BigInteger.valueOf(i)) < num) ; i++){ |
|
|
|
|
|
 |
wtd
|
Posted: Tue Jun 27, 2006 10:49 pm Post subject: (No subject) |
|
|
Java objects do not support operator overloading.
Have you tried reading through a basic introduction to Java, to get a grasp on the fundamentals? I ask because the things you keep encountering problems with are pretty basic. |
|
|
|
|
 |
cool dude

|
Posted: Wed Jun 28, 2006 7:42 pm Post subject: (No subject) |
|
|
wtd wrote: Java objects do not support operator overloading.
Have you tried reading through a basic introduction to Java, to get a grasp on the fundamentals? I ask because the things you keep encountering problems with are pretty basic.
i did read through the beginning parts so far. then it gets a lot more complicated and i want to practice this stuff before i move on to make sure i fully understand it. also no where in your tutorial did you explain how to use BigIntegers. also i still don't understand how i would make a counted loop to go up to such a large number? |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
wtd
|
Posted: Wed Jun 28, 2006 10:38 pm Post subject: (No subject) |
|
|
cool dude wrote: also no where in your tutorial did you explain how to use BigIntegers.
For very good reason.
There are 3000+ classes. If I tried to write tutorials for all of them, I'd die of old age before finishing. What I can do is explain the way objects and classes work, and the rules they play by. Then, knowing that, you can figure out the classes you need to use. |
|
|
|
|
 |
|