hi,
i'm writing an internet maths application at the moment, and am using PHP to
do it, but it only (only..!) seems to handle numbers in the range -10billion
to +10billion or in that ballpark.
I was wondering what sized numbers java can handle. I used a JAVA
application once that calculated hcf's of 2 numbers, and the numbers it
handled were huge (and i mean huge). Not sure how it was doing it actually.
But anyway, what are java limits as far as number size goes?
jeremy
Joe Fischer - 04 Apr 2004 03:01 GMT
>hi,
>
[quoted text clipped - 8 lines]
>
>jeremy
INTEGER.MAX_VALUE = (2^31)-1
INTEGER.MIN_VALUE = -2^31
LONG.MAX_VALUE = (2^63)-1
LOG.MIN_VALUE = -2^63
FLOAT.MAX_VALUE = (2-2^(-23))·2^127
FLOAT.MIN_VALUE = 2^(-149)
DOUBLE.MAX_VALUE = (2-2^(-52))·2^1023
DOUBLE.MIN_VALUE = 2^(-1047)
-------
Remove underscores from e-mail address.
Roedy Green - 07 Apr 2004 01:10 GMT
>INTEGER.MAX_VALUE = (2^31)-1
>INTEGER.MIN_VALUE = -2^31
for future reference these limits are posted at
http://mindprod.com/jgloss/primitive.html
--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Raymond DeCampo - 05 Apr 2004 02:55 GMT
> hi,
>
[quoted text clipped - 6 lines]
> handled were huge (and i mean huge). Not sure how it was doing it actually.
> But anyway, what are java limits as far as number size goes?
Someone else has posted the limits for the native types so I won't
repeat them here. But I will point out that the JDK comes with the
BigInteger and BigDecimal classes which will allow you to do arbitrary
precision arithmetic without size limits.
Ray
Robert Klemme - 09 Apr 2004 22:10 GMT
> > hi,
> >
[quoted text clipped - 13 lines]
>
> Ray
For further reading:
http://java.sun.com/j2se/1.4.2/docs/api/java/math/BigDecimal.html
http://java.sun.com/j2se/1.4.2/docs/api/java/math/BigInteger.html
robert