[kaffe] MIN_VALUE of java.lang.Double

Kevin D. Kissell kevink at mips.com
Thu Oct 10 01:47:34 PDT 2002


A couple of observations here.  First of all, I wonder 
which version of libc you are using such that you have 
this bug. I have compiled and run your test case on several 
Linux systems, including a MIPS/Linux box running a port
of Red Hat 7.1 and an old PC running Red Hat 6.0, 
and I don't get the behavior you describe.  What I get is:

% cat t.c
#include <stdlib.h>
extern int errno;

int main(int argc, char* argv[]) {
   double d = strtod(argv[1], NULL);
   printf("%s %d %40.20e\n",argv[1], errno, d);
}

% 78 ./t 4.94065645841246544e-324
4.94065645841246544e-324 0              4.94065645841246544177e-324
% ./t 4.9e-324
4.9e-324 0              4.94065645841246544177e-324
% ./t 5.0e-324
5.0e-324 0              4.94065645841246544177e-324

I strongly suggest that you upgrade your library, 
rather than break kaffe to be compatible with it.
I see that you are running an old kernel, but surely 
there is a compatable glibc update available?

Secondly, I repeat my observation that the true
definition of MIN_VALUE for a JVM Double
precision floating-point type is correctly defined
in the second edition of the JVM spec as
2**(-(2**11 - 2) - 53 + 1) which is to say
2**(-1074).  The full decimal representation
of that value (according to dc) would be
4.9406564584124654417656879286822137
236505980261432476442558568250067550
727020875186529983636163599237979656
469544571773092665671035593979639877
479601078187812630071319031140452784
581716784898210368871863605699873072
305000638740915356498438731247339727
316961514003171538539807412623856559
117102665855668676818703956031062493
194527159149245532930545654440112748
012970999954193198940908041656332452
475714786901472678015935523861155013
480352649347201937902681071074917033
322268447533357208324319360923828934
583680601060115061698097530783422773
183292479049825247307763759272478746
560847782037344696995336470179726777
175851256605511991315048911014510378
627381672509558373897335989936648099
411642057026370902792427675445652290
87538682506419718265533447265625e-324

Any software which implements a range check
using truncated or rounded decimal values such 
as those which appear in the Java language spec 
and  which used to appear in the JVM spec will 
either reject legal IEEE values or accept illegal ones.

            Regards,

            Kevin K.

----- Original Message ----- 
From: "Ito Kazumitsu" <ito.kazumitsu at hitachi-cable.co.jp>
To: <kaffe at kaffe.org>
Sent: Thursday, October 10, 2002 3:42 AM
Subject: Re: [kaffe] MIN_VALUE of java.lang.Double


> In message "Re: [kaffe] MIN_VALUE of java.lang.Double"
>     on 02/10/09, "Kevin D. Kissell" <kevink at mips.com> writes:
> 
> > I don't have the revised Java Language Specification handy to
> > see of they fixed it.  In any case, I believe that kaffe should be using 
> > the value that corresponds to the true minimum denormalized IEEE 
> > double.
> 
> http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#230798
> 
> reads:
> 
>   The smallest positive finite nonzero literal of type double is
>   4.94065645841246544e-324.
> 
>   A compile-time error occurs if a nonzero floating-point literal is
>   too small, so that, on rounded conversion to its internal representation,
>   it becomes a zero.
> 
> So I understand 4.94065645841246544e-324 should be used,  but the
> problem is that a compile-time error occurs where some poor strtod
> converts 4.94065645841246544e-324 to zero.
> 
> Formerly, precompiled Klasses.jar was included in the kaffe package
> so I did not have to compile java/lang/Double.java.  But now we
> have to make rt.jar ourselves.  So the compile-time error that
> java/lang/Double.java causes is really annoying.
> 
> This is how strtod of my machine works:
> 
> $ uname -smr
> Linux 2.0.38 i686
> $ cat Double.c
> #include <stdlib.h>
> extern int errno;
> 
> int main(int argc, char* argv[]) {
>    double d = strtod(argv[1], NULL);
>    printf("%s %d %40.20e\n",argv[1], errno, d);
> }
> 
> $ cc -o Double Double.c
> $ ./Double 4.94065645841246544e-324
> 4.94065645841246544e-324 0               0.00000000000000000000e+00
> $ ./Double 4.9e-324
> 4.9e-324 0               0.00000000000000000000e+00
> $ ./Double 5e-324
> 5e-324 0              4.94065645841246544177e-324
> 
> _______________________________________________
> kaffe mailing list
> kaffe at kaffe.org
> http://kaffe.org/cgi-bin/mailman/listinfo/kaffe
> 




More information about the kaffe mailing list