Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Tools / April 2004

Tip: Looking for answers? Try searching our database.

number handling in java

Thread view: 
Jeremy Watts - 03 Apr 2004 12:19 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.