Question about TomEE and OpenEJB.

classic Classic list List threaded Threaded
3 messages Options
A Z
Reply | Threaded
Open this post in threaded view
|

Question about TomEE and OpenEJB.

A Z
-Do floats and doubles in TomEE, as well as in OpenEJB,

still have the same floating point overflow and underflow

arithmetic phenomena as in Java Standard Edition?


-I refer to the following kind of phenomonen:


Double a = 0.1;


Double b = 0.1;


Double x = a*b;


out.println(x == 0.01); //actually prints false.



-Do TomEE or OpenEJB have some option to get

rid of overflow and underflow entirely, by means of some kind

of option?  If so, what is that?



Reply | Threaded
Open this post in threaded view
|

Re: Question about TomEE and OpenEJB.

David Jencks-3
As Romain said in response to your previous question, the capabilities provided as part of any software implemented on top of the jre, such as tomee or openejb, don’t affect arithmetic operations in the jre in any way. After carefully analyzing your actual needs you might investigate the BigInteger and BigDecimal classes to see if they will support whatever you are trying to do.  I don’t think you will find any way to exactly model the set of real numbers, rational numbers, or even integers on any computer built now or in the future.

Btw while not an expert I don’t think your example illustrates overflow of underflow but rather that decimal fractions can’t be converted accurately to finite binary fractions. This is why eg cobol used binary coded decimal.

David Jencks
Sent from my iPhone

> On Mar 12, 2018, at 8:37 PM, A Z <[hidden email]> wrote:
>
> -Do floats and doubles in TomEE, as well as in OpenEJB,
>
> still have the same floating point overflow and underflow
>
> arithmetic phenomena as in Java Standard Edition?
>
>
> -I refer to the following kind of phenomonen:
>
>
> Double a = 0.1;
>
>
> Double b = 0.1;
>
>
> Double x = a*b;
>
>
> out.println(x == 0.01); //actually prints false.
>
>
>
> -Do TomEE or OpenEJB have some option to get
>
> rid of overflow and underflow entirely, by means of some kind
>
> of option?  If so, what is that?
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Question about TomEE and OpenEJB.

Romain Manni-Bucau
You can have a look to BigDecimal, and some 3rd party libraries like gmp
(there are java bindings). But JavaEE isnt linked to that at all.

Le 13 mars 2018 05:58, "David Jencks" <[hidden email]> a écrit :

> As Romain said in response to your previous question, the capabilities
> provided as part of any software implemented on top of the jre, such as
> tomee or openejb, don’t affect arithmetic operations in the jre in any way.
> After carefully analyzing your actual needs you might investigate the
> BigInteger and BigDecimal classes to see if they will support whatever you
> are trying to do.  I don’t think you will find any way to exactly model the
> set of real numbers, rational numbers, or even integers on any computer
> built now or in the future.
>
> Btw while not an expert I don’t think your example illustrates overflow of
> underflow but rather that decimal fractions can’t be converted accurately
> to finite binary fractions. This is why eg cobol used binary coded decimal.
>
> David Jencks
> Sent from my iPhone
>
> > On Mar 12, 2018, at 8:37 PM, A Z <[hidden email]> wrote:
> >
> > -Do floats and doubles in TomEE, as well as in OpenEJB,
> >
> > still have the same floating point overflow and underflow
> >
> > arithmetic phenomena as in Java Standard Edition?
> >
> >
> > -I refer to the following kind of phenomonen:
> >
> >
> > Double a = 0.1;
> >
> >
> > Double b = 0.1;
> >
> >
> > Double x = a*b;
> >
> >
> > out.println(x == 0.01); //actually prints false.
> >
> >
> >
> > -Do TomEE or OpenEJB have some option to get
> >
> > rid of overflow and underflow entirely, by means of some kind
> >
> > of option?  If so, what is that?
> >
> >
> >
>