Results 1 to 2 of 2
Thread: Question about what this do.
 07032010, 08:12 AM #1Member
 Join Date
 Jun 2010
 Posts
 34
 Rep Power
 0
Question about what this do.
Java Code:for(int i = 0; i<inputting; i++){ System.out.print("Enter Number "+(i+1) + ": "); num[i]= kbd.next(); System.out.print("Enter Original Base: "+(i+1) + ": "); x[i] = Integer.parseInt(kbd.next()); int l = num[i].length(); int v = 0; for(int j = l1; j>=0; j){ if(Character.isLetter(num[i].charAt(v))){ a = calculate(num[i].charAt(v)); } else a = Integer.parseInt(Character.toString(num[i].charAt(v))); z = z + (a*(int)Math.pow(x[i], j)); v++; // Returns the value of the first argument raised to the power of the second argument. }
especially the if else statement w/ math.pow.
 07032010, 09:35 AM #2
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,422
 Blog Entries
 7
 Rep Power
 28
You didn't write this piece of code yourself did you? No? Good, because it's a lousy way to convert a String representation of a number in any base to an integral number; w.r.t. that pow( ... ) method: the author commented the method in the last line of the 'elsepart' and because it's a method from the Math class it is completetly documented in the API documentation. My tip: throw that piece of code away and read the API documentation for the Integer class; it does exactly what you want and it does it without using that the pow( ... ) method.
kind regards,
Jos
Similar Threads

Question mark colon operator question
By orchid in forum Advanced JavaReplies: 9Last Post: 12192010, 09:49 AM 
Please help me PLEASe with this question
By javanew in forum New To JavaReplies: 2Last Post: 03262010, 01:45 PM 
RMI question
By alvandrood in forum New To JavaReplies: 1Last Post: 09142009, 01:36 PM 
Need help on this question
By Deon in forum New To JavaReplies: 3Last Post: 01272008, 04:58 PM 
question about rmi
By leonard in forum New To JavaReplies: 1Last Post: 08062007, 05:19 AM
Bookmarks