Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 booleans
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
kevin Noronha




PostPosted: Sat Mar 08, 2008 8:29 pm   Post subject: booleans

umm...anyone know how i can check, if when i divide 2 integers, if they are integers or not?

here is the code

import java.util.*;

class Factors{
public static HashSet primes(int high){
HashSet primeset=new HashSet();
for(int i=0;i>high;i++){
if ((i/2)!=Integer){
primeset.add(i);
}
}
}
}
Sponsor
Sponsor
Sponsor
sponsor
Clayton




PostPosted: Sat Mar 08, 2008 8:34 pm   Post subject: RE:booleans

Check if the value returned is equal to the value returned casted to an int?
A.J




PostPosted: Sat Mar 08, 2008 9:04 pm   Post subject: Re: booleans

to check if x is an integer, round(x) must equal to x.
HeavenAgain




PostPosted: Sat Mar 08, 2008 9:24 pm   Post subject: RE:booleans

why not just
code:
if (i%2 == 0) // if is 0 then there is no remainder (decimal), or else is 1
Integer is a reference type, you cannot compare a int (data type); (i/2), with a reference type; Integer.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: