Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   system specific limit (http://www.velocityreviews.com/forums/t621949-system-specific-limit.html)

asit 06-24-2008 08:25 AM

system specific limit
 
Does java provide any specific library to know the limit of different
data types like limits.h in C ???


asit 06-24-2008 08:46 AM

Re: system specific limit
 
On Jun 24, 1:41 pm, Wayne <nos...@all.4me.invalid> wrote:
> asit wrote:
> > Does java provide any specific library to know the limit of different
> > data types like limits.h in C ???

>
> None is needed. Unlike C, the primitive datatypes in Java have
> very specific meaning that do not change with the CPU you
> happen to be using. See the Java Language Specification,
> or any decent textbook.
>
> -Wayne


So answer to my question is a Strict No

Andreas Leitgeb 06-24-2008 08:48 AM

Re: system specific limit
 
Wayne <nospam@all.4me.invalid> wrote:
> asit wrote:
>> Does java provide any specific library to know the limit of different
>> data types like limits.h in C ???


> None is needed. Unlike C, the primitive datatypes in Java have
> very specific meaning that do not change with the CPU you
> happen to be using. See the Java Language Specification,
> or any decent textbook.


Nevertheless, the limits of each primitive type can still be
obtained: each primitive has it's wrapper, like "Integer"
for "int", and these wrappers have static fields for the
maximum and minimum values of their corresponding primitives.
(MAX_VALUE and MIN_VALUE)
There are also some more such static fields with that kind
of information, e.g. "SIZE" and several more for float/double.


Roedy Green 06-24-2008 10:40 AM

Re: system specific limit
 
On Tue, 24 Jun 2008 01:25:35 -0700 (PDT), asit <lipun4u@gmail.com>
wrote, quoted or indirectly quoted someone who said :

>Does java provide any specific library to know the limit of different
>data types like limits.h in C ???


You don't need one. All sizes are absolutely nailed down in the JLS.
This is one of the nicest features of Java. The same program means
the same thing on all platforms in terms of the range of possible
values of each variable.


See http://mindprod.com/jgloss/sizeof.html
http://mindprod.com/jgloss/jls.html
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Roedy Green 06-24-2008 11:33 AM

Re: system specific limit
 
On Tue, 24 Jun 2008 01:46:38 -0700 (PDT), asit <lipun4u@gmail.com>
wrote, quoted or indirectly quoted someone who said :

> So answer to my question is a Strict No


the answer is "sort of". There are no built-in constants for the
number of bits in the various primitives (though they are defined in
the JLS), but there are constants for the min/max values of various
primitives. E.g. Long.MIN_VALUE.

See http://mindprod.com/jgloss/sizeof.html
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com


All times are GMT. The time now is 02:34 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.