This discussion is archived
1 2 Previous Next 22 Replies Latest reply: Mar 15, 2010 5:20 PM by 843789

# BigDecimal Range

Currently Being Moderated
Hi

Please let me know if there is any range for BigDecimal?

If so what is the range?

• ###### 1. This Thread is now moved
Currently Being Moderated
Note: This thread was originally posted in the Swing forum, but moved to this forum for closer topic alignment.
• ###### 2. Re: BigDecimal Range
Currently Being Moderated
The range of BigDecimal is effectively only limited by available memory (and the fact that arrays in Java are indexed by int variables, but you'll likely hit the other restriction earlier).

For pretty much all uses, the range is effectively unlimited.
• ###### 3. Re: BigDecimal Range
Currently Being Moderated
JoachimSauer wrote:
For pretty much all uses, the range is effectively unlimited.
Would they be accurate up to say 1^(-1,000,000)? I've yet to reach such limits but from my own calculations it is feasible that I may need them to be that accurate. Maybe = |
• ###### 4. Re: BigDecimal Range
Currently Being Moderated
BigDecimal is as accurate as documented across its whole range (it's an arbitrary precision data type).

The problem is not that it becomes inaccurate at some size, but that it isn't able to represent numbers outside a certain range.
• ###### 5. Re: BigDecimal Range
Currently Being Moderated
mrwobbles wrote:
JoachimSauer wrote:
For pretty much all uses, the range is effectively unlimited.
Would they be accurate up to say 1^(-1,000,000)?
One raised to the power negative one million?
``````System.out.println(Math.pow(1, -1000000));

...

1.0``````
• ###### 6. Re: BigDecimal Range
Currently Being Moderated
jverd wrote:
mrwobbles wrote:
JoachimSauer wrote:
For pretty much all uses, the range is effectively unlimited.
Would they be accurate up to say 1^(-1,000,000)?
One raised to the power negative one million?
``````System.out.println(Math.pow(1, -1000000));

...

1.0``````
I think I might have missed a 0 there... So the maximum scale is the maximum 32 bit integer? I think that will be enough but just for shits and giggles say I needed a scale bigger than that, what's my best option?
• ###### 7. Re: BigDecimal Range
Currently Being Moderated
``````System.out.println(Math.pow(1, -1000000));

...

1.0``````
Spoilsport
• ###### 8. Re: BigDecimal Range
Currently Being Moderated
So the maximum scale is the maximum 32 bit integer?
That's an absolutely colossal number - do you realise how big it is?
• ###### 9. Re: BigDecimal Range
Currently Being Moderated
mrwobbles wrote:
jverd wrote:
mrwobbles wrote:
JoachimSauer wrote:
For pretty much all uses, the range is effectively unlimited.
Would they be accurate up to say 1^(-1,000,000)?
One raised to the power negative one million?
``````System.out.println(Math.pow(1, -1000000));

...

1.0``````
I think I might have missed a 0 there... So the maximum scale is the maximum 32 bit integer? I think that will be enough but just for shits and giggles say I needed a scale bigger than that, what's my best option?
Find a different universe
• ###### 10. Re: BigDecimal Range
Currently Being Moderated
mrwobbles wrote:
I think that will be enough but just for kicks and giggles say I needed a scale bigger than that, what's my best option?
Work with logarithms.
• ###### 11. Re: BigDecimal Range
Currently Being Moderated
roger.bagnall wrote:
So the maximum scale is the maximum 32 bit integer?
That's an absolutely colossal number - do you realise how big it is?
2,147,483,647 I think. Which was the starting budget if you cheated in SimCity 2000.

Compared to the scale of the combined national and private debt of the [USA |http://www.usdebtclock.org/] it is small. Maybe that says more about that debt than the size of the number. In comparison to infinity it is next to nothing, but I wanted to know if it was possible to represent a number that large in Java. I guess not.
• ###### 12. Re: BigDecimal Range
Currently Being Moderated
mrwobbles wrote:
2,147,483,647 I think.
Uhm, check Integer.MAX_VALUE
• ###### 13. Re: BigDecimal Range
Currently Being Moderated
PhHein wrote:
mrwobbles wrote:
2,147,483,647 I think.
Uhm, check Integer.MAX_VALUE
``````public class run {
public static void main(String[] args)  {
System.out.print(Integer.MAX_VALUE);
}
}``````
• ###### 14. Re: BigDecimal Range
Currently Being Moderated
Exactly, so you are way off.
1 2 Previous Next