🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #17582

Re: Floating-Point Range of Values...

#17582
From: Steve Schafer (TeamB)
Date: Wed, 21 Oct 1998 00:00
35 lines
1937 bytes
On Wed, 21 Oct 1998 18:50:53 +0700, Rusli Usman <mrusli67@cbn.net.id>
wrote:

>I understand java's Floating-Point data type consists of float (32-bits)
>and double (64-bits).  If I want to find out the range of a type, for
>example, byte which has a maximum value of 127, all I have to do is as
>follows:
>
>byte bValue = 127;
>
>System.out.println("Min of Byte: "+ ++bValue);
>
>The output gives me:
>
>Min of Byte:-128
>
>So, how do I do that with floating-point?  If I do ezactly like the byte
>data type, I don't see the min value.  I know the min and max value of
>float, but how do I prove it in the code?

Your code that works with byte variables doesn't "prove" anything.
You've come up with a clever trick that happens to give you the right
answer. There's nothing in the Java language specification that says
that incrementing an integer-type variable that has the maximum value
will give you the corresponding integer-type variable with the minimum
value; it's just a consequence of the definitions of the widening and
narrowing operations that take place inside the Java VM. The only way
to "prove" that a variable contains the minimum or maximum value is to
compare the value to the limiting values given in the language
specification.

By the way, the minimum and maximum values for float are -INF and
+INF, respectively.

-Steve
Technical Details
Message-ID: <369d498a.253050490@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <362DCA9D.CEFABA69@cbn.net.id>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,da07c345f9ebf065
X-Google-Attributes: gidf74b3,public
From: pandeng@telepath.com (Steve Schafer (TeamB))
Subject: Re: Floating-Point Range of Values...
Date: 1998/10/21
Message-ID: <369d498a.253050490@forums.borland.com>
X-Deja-AN: 403687120
Content-Transfer-Encoding: 7bit
References: <362DCA9D.CEFABA69@cbn.net.id>
Content-Type: text/plain; charset=us-ascii
Organization: TeamB
Mime-Version: 1.0
Reply-To: pandeng@telepath.com
Newsgroups: borland.public.jbuilder.java.language