Discussion:
Question about TomEE and OpenEJB.
A Z
2018-03-13 03:37:06 UTC
Permalink
-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?
David Jencks
2018-03-13 04:57:57 UTC
Permalink
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
Post by 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?
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?
Romain Manni-Bucau
2018-03-13 06:41:11 UTC
Permalink
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.
Post by David Jencks
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
Post by 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?
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?
Loading...