My method seems to only work for all int less than 2^10. If it is greater than or equal to this value then it just returns 2^32. I'm not sure how my program is even getting this. I need to make it work for all int less than or equal to 2^15. Can anybody at least see why it's returning 2^32 for int greater than or equal to 2^10? If so then let me know please.
public static int DecToBin(int num) { int binNum = 0; int divisor = num; int mod = 0; int exp =0; while(divisor != 0){ mod = divisor%2; divisor = divisor/2; if(mod==1){ binNum = (int) (binNum + (Math.pow(10, exp))); } exp++; } return binNum; }