Matt Wilde wrote:This is not quite like it sounds.
int [] a = {1234}; //this represents 1,234
int [] b = {7777}; //this represents 7,777
the reason for this notation is to represent very large numbers i.e. 1,111,111,111,111. instead of it being rep as a "long" it is put into an array {111111111111111} or whatever. you get the idea.
my question.... adding "a" and "b" arrays to form a number like 9,011.
does that make sense?
Matt Wilde wrote:sorry Henry i edited the first post i didn't realize that {1111111111111} was just one value. forgot.
ya but what happens if i try to do math on java with an number that has 100 integers or more? thats why i want to represent each integer in a larger number as a spot in one array
Matt Wilde wrote:yes i would use BigInteger in a heartbeat if it weren't that we had to use arrays.
BUT of course this does not compile because i get outofbounds exception. because h.b.length is not the same as b.length (current obj). tips?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
How do you know you will need a 100-element array? Why not use the same size as the input array? Why are you not cloning the array, because the clone() method on a primitive array does what you want. There is no such thing as a deep copy of a primitive. There is only a copy.Matt Wilde wrote: . . .
Paul Clapham wrote:Unorthodox? Nothing really off-the-wall there. It's just that beginners tend to write too much code. Example:
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |