aspose file tools*
The moose likes Beginning Java and the fly likes java BigNumber 2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java BigNumber 2" Watch "java BigNumber 2" New topic
Author

java BigNumber 2

Jose Carrillo
Greenhorn

Joined: Nov 13, 2003
Posts: 17
hi it's me again well when I say inicialized to zero I meant that that for example if the user enter a number for example 15 It won't appear 0000000015. IT has to be 15. I really I have not Idea how to do that I was planning with aloop but I have not Idea how to do it. if any one could help me I would appreciated. here es my code:
public class GiantNumber
{
private short[] digitsArray;
public GiantNumber()
{
digitsArray = new short [100];
}
public void add()
{
GiantNumber a = new GiantNumber(3);
GiantNumber b = new GiantNumber(5);
a.add(b);
}
public void add(GiantNumber b)
{
}
public GiantNumber(int i)
{
}
}
thanks!
Kim Kantola
Ranch Hand

Joined: May 17, 2001
Posts: 274
When you say "It won't appear 0000000015" do you mean that you are having trouble displaying the value? Is this a question about how to print out the value?
Jose Carrillo
Greenhorn

Joined: Nov 13, 2003
Posts: 17
No what I mean is let's say that the user input the number: 15, but since it is an array of 100 digits it would appear a bunh od zeros and then the 15 something like 0000000000000000000000000000000000015. I want to get rid of those zeros.BUT I DO NOT KNOW HOW. thanks.
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
I don't see any code above that is concerned with displaying the number. If you were to post such code that you are working on, it might become easier to suggest a nudge in the right direction.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
For one thing, where is the least significant digit stored in your array? I'll assume that it's in the [0] position.
So to truncate the zeroes you need to find in your array the most significant digit of the number the array is supposed to represent. The most significant digit will be the one that has all zeroes proceeding it. So in the example you gave, 00000000015, the most significant digit is 1, and it may be found in the [1] position of your array (assuming 5 is in the [0] position). Once you have determined at which position your most significant digit is at in the array, then all you need to do is display the number from the most significant digit down to the least significant digit (the one in the [0] position of your array).
The small challenge for you will be coming up with an algorithm to scan your array and determine where in the array your most significant digit lies.
HTH
Kim Kantola
Ranch Hand

Joined: May 17, 2001
Posts: 274
Yea, I agree with Dick, need to see some example code to have an idea of what you are trying to do. It's hard to understand what you are asking without an idea of the code you have so far.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java BigNumber 2